Secure Shell and Secure FTP over Custom Ports

Ssh and sftp

Everyone knows they should be using ssh instead of telnet, and sftp instead of ftp. I regularly drop to the command line and use these utilities. By default, these run on port 22. But, sometimes you need to connect to a custom port number because the server is bound to something other than port 22. How do you specify the custom port number?

  1. For secure shell, use the command line:

    > ssh user@server.domain.com -p port
  2. For secure FTP, use the command line:

    > sftp -oPort=port user@server.domain.com

The above assumes you are connecting to server.domain.com with login user. Obviously, change the values to match your situation. Also, note that the “-p” option does not exist in sftp — so much for consistency amongst commands — so you will get an error message if you attempt for format the sftp command like the ssh command. I am mentioning this because that’s exactly what I did!