sftp-to-ftp
v1.1.3
Published
[](https://www.npmjs.com/package/sftp-to-ftp) [](https://packagephobia.now.sh/result?p=sftp-to-ftp) [
- Interactive Mode (Prompt for details):
Example output:npx sftp-to-ftpEnter SSH host/IP: 192.168.0.105 Enter SSH port (Default: 22): 22 Enter SSH username (Leave empty if not needed): root Enter SSH password (Leave empty if not needed): ******** Enter FTP host/IP (Default: 127.0.0.1): 127.0.0.1 Enter FTP port (Default: 21): 21 🟢 FTP server listening! ftp://127.0.0.1:21
Windows File Explorer Tip: Simply enter
ftp://127.0.0.1:21(or your custom host/port) in the address bar to browse your SFTP server like a local folder!
Direct Arguments (Fully automated):
npx sftp-to-ftp --ssh-host 192.168.0.105 --ssh-port 22 --ssh-user root --ssh-pass PWD --ftp-host 127.0.0.1 --ftp-port 21Anonymous Mode (No SSH credentials required if pre-authenticated):
npx sftp-to-ftp --ssh-host 192.168.0.105 --ssh-port 22 --ftp-host 127.0.0.1 --ftp-port 21
Programmatic Usage
import { SSHToFTPBridge } from 'sftp-to-ftp';
// Create bridge to SSH server
const bridge = new SSHToFTPBridge(
{
host: 'your-ssh-server',
port: 22,
username: 'your-user',
password: 'your-pass'
},
{
host: '127.0.0.1' // Optional FTP host
port: 21 // Optional FTP port
}
);
// The FTP server is now running on port 21
// Connect with any FTP client to ftp://127.0.0.1:21
// To shutdown:
// await bridge.terminate();API Reference
Class: SSHToFTPBridge
Constructor
new SSHToFTPBridge(sshConfig: SSHConfiguration, options?: { port?: number })sshConfig(Object):host(string) - SSH server hostname/IPport(number) - SSH port (default: 22)username(string) - SSH usernamepassword(string) - SSH password
options(Object, optional):host(string) - FTP server hostname/IP (default: 127.0.0.1)port(number) - FTP server port (default: 21)
Methods
terminate(): Promise<void>- Shuts down the FTP server and disconnects from SSH
Class: FTPSession
(Advanced usage - for custom FTP server implementations)
Properties
authenticated(boolean) - Session authentication statuscwd(string) - Current working directorytransferType(string) - Current transfer type (A/I)
Methods
send(code: number, message: string): void- Send FTP responseresolvePath(relativePath: string): string- Resolve relative paths
Supported Commands
| Command | Description | Status | |---------|----------------------------------|--------| | USER | Authentication username | ✅ | | PASS | Authentication password | ✅ | | LIST | Directory listing | ✅ | | RETR | Download file | ✅ | | STOR | Upload file | ✅ | | DELE | Delete file | ✅ | | MKD | Create directory | ✅ | | RMD | Remove directory | ✅ | | RNFR | Rename from | ✅ | | RNTO | Rename to | ✅ | | CWD | Change working directory | ✅ | | PWD | Print working directory | ✅ | | PASV | Passive mode transfer | ✅ | | PORT | Active mode transfer | ✅ | | TYPE | Transfer type (A/I) | ✅ | | SIZE | Get file size | ✅ | | MDTM | Get file modification time | ✅ | | QUIT | Disconnect | ✅ |
Contributing
Contributions are welcome! Please open an issue or submit a pull request on the GitHub repository.
License
sftp-to-ftp is licensed under the MIT license.
Author
||
|:---:|
|@SheikhAminul|
