Ubuntu – sftp – how to connect to non-default port

command linesftpssh

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?

Best Answer

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).