I want to connect to server via sftp using specific IP and a specific (non-default) PORT .
How can I choose non-default port when connecting using sftp?
I want to connect to server via sftp using specific IP and a specific (non-default) PORT .
How can I choose non-default port when connecting using sftp?
You can use the -oPort=port_number option
sftp -oPort=port_number host_name
sftp - secure file transfer program
sftp [-1Cv] [-B buffer_size] [-b batchfile] [-F ssh_config] [-o ssh_option] [-P sftp_server_path] [-R num_requests] [-S program] [-s subsystem | sftp_server] host
-o ssh_option
Can be used to pass options to ssh in the format used in ssh_config(5). This is useful for specifying options for which there is no separate sftp command-line flag. For example, to specify an alternate port use:sftp -oPort=24. For full details of the options listed below, and their possible values, see ssh_config(5).
You can use -P option or -oPort option to SFTP to a server from a specific port.
sftp -oPort=port_no username@x.x.x.x
eg. sftp -oPort=8022 rahul@x.x.x.x
or
sftp -P port_no username@x.x.x.x
eg. sftp -P 8022 rahul@x.x.x.x
Note that -P is capital P not small
sftp://xx.xx.xxx.xxx:port
ex. sftp://158.45.47.66:4343
– Meet Vaishnani Aug 10 '17 at 05:06sftpserver using a browser or using a terminal/command-line? – Yaron Aug 10 '17 at 05:11sftp -oPort=2222 LOC-FILE.TXT user123@remote.host:Downloads/REMOTE-FILE.TXTYou need to use the username of the remote system (e.g, user123) in order to properly log onto that system. – PatS Apr 24 '25 at 19:37