sftp - how to connect to non-default port?

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

man sftp

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 [email protected]

eg. sftp -oPort=8022 [email protected]

or

sftp -P port_no [email protected]

eg. sftp -P 8022 [email protected]

Note that -P is capital P not small