ssh_upload
Transfer files from a local system to a remote server via SSH. Specify server name, local file path, and remote destination path to securely upload files across connected systems.
Instructions
Upload file to remote SSH server
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| localPath | Yes | Local file path | |
| remotePath | Yes | Remote destination path | |
| server | Yes | Server name |
Implementation Reference
- src/tool-registry.js:14-20 (registration)Registration of 'ssh_upload' tool in the core group of TOOL_GROUPS exportcore: [ 'ssh_list_servers', 'ssh_execute', 'ssh_upload', 'ssh_download', 'ssh_sync' ],
- src/ssh-manager.js:346-381 (helper)Core implementation of SSH file upload using SFTP fastPut, with ~ path resolution and local file existence check. This is the primary logic executed by the ssh_upload tool.async putFile(localPath, remotePath) { // SFTP doesn't resolve ~ automatically, we need to get the real path let resolvedRemotePath = remotePath; if (remotePath.includes('~')) { try { const homeDir = await this.resolveHomePath(); // Replace ~ with the actual home directory // Handle both ~/path and ~ alone if (remotePath === '~') { resolvedRemotePath = homeDir; } else if (remotePath.startsWith('~/')) { resolvedRemotePath = homeDir + remotePath.substring(1); } else { // If ~ is not at the beginning, don't replace it resolvedRemotePath = remotePath; } } catch (err) { // If we can't resolve home, throw a more descriptive error throw new Error(`Failed to resolve home directory for path: ${remotePath}. ${err.message}`); } } const sftp = await this.getSFTP(); return new Promise((resolve, reject) => { // Check if local file exists and is readable if (!fs.existsSync(localPath)) { reject(new Error(`Local file does not exist: ${localPath}`)); return; } sftp.fastPut(localPath, resolvedRemotePath, (err) => { if (err) reject(err); else resolve(); }); }); }