How to Find and Change SFTP Port Number

SFTP means SSH File Transfer Protocol or Secure File Transfer Protocol. It is a file transfer protocol but under the umbrella of SSH as one of its subsystems. Its purpose is to provide a secure channel of communications, in this case transfer of files. As with FTP, SFTP runs on a port. SFTP Default port number is generally 22. In this tutorial we will guide you on how to find and change SFTP port number.

Step#1: Default SFTP Port
First of all, let’s open up the terminal application and type
cat /etc/ssh/sshd_config
This will open up the ssh configuration file. You can scroll up to view the SFTP port number. Over here, we can see that the sftp default port number is 22.
default port for SFTP

Step#2: Edit SFTP Default port
To change the SFTP port number, let’s open the ssh configuration file in a visual editor by typing
vi /etc/ssh/sshd_config
In the editor, use down arrow key to move the cursor on the port number, but before you can actually make any changes, you have to move to the insert mode. For that, press the ‘I’ key on the keyboard.
Now you can type the port number which you want to use. Once done, press shift and hit “Z” twice on the keyboard. This will save the changes and exit the editor.
changing the default port

Step#3: Finalize the Changes
Now you must restart the ssh service for the changes take effect. For that, type the command
service ssh restart
and hit Enter.
restart service to implement changes

Step#4: Verify the Port value
Now when you view the ssh configuration file, you will notice that the port number has changed successfully.
the default port has changed