Secure File Transfer Protocol is a protocol used to transfer files in an encrypted way. The SFTP protocol is integrated and provided by the SSH (Secure Shell) protocol. This means the SFTP runs under the SSH service. The SFTP uses the security, encryption, authentication, and authorization features of the SSH.
SFTP Port Number TCP 22
Surprisingly the SFTP protocol runs with the SSH service at the same port. This means SFTP service is provided via the TCP 22 port number. It may confuse you but the reality is that the SFTP is a submodule of the SSH and we can think that the SFTP is a feature of the SSH protocol.
Connect SFTP Server
There are different sftp client tools where Linux distributions provide them with the SSH package. We can connect the SFTP server via its default port by providing the remote SFTP server IP address or hostname with the username.
$ sftp [email protected]
Connect SFTP Server with Non-default Port Number
Even the SSH and SFTP services run over the default TCP 22 port there are some cases where the non-default port is configured for the SSH and SFTP. The sftp command can be used to connect the non-default port numbers by adding the port number at the end of the remote SFTP server IP address or hostname with the double colon like below.
sftp [email protected]:PORT
So if the remote SFTP port number is 2222 we can connect this SFTP port like below.
$ sftp [email protected]:2222
Check SFTP Port In Linux
The SFTP protocol is popularly used in Linux distributions like Ubuntu, Debian, CentOS, RHEL, Mint, etc. In a Linux system, we can check the SFTP port status with the
netstat command like below. We will check if the SSH port is listening as SFTP is provided via the SSH port.
$ netstat -tl