Applies to: OpenSSH (SFTP) on Linux servers, and SFTP clients such as sftp, scp, FileZilla and WinSCP; tested with OpenSSH 9.9 on AlmaLinux 9

SFTP uses TCP port 22, the same port as SSH, because SFTP (SSH File Transfer Protocol) runs inside an SSH connection. There is no separate SFTP service to open: if you can log in with SSH, you can usually transfer files with SFTP on the same port, with the same username and password or SSH key.

SFTP, FTPS and FTP are different

  • SFTP: file transfer over SSH, port 22. Encrypted.
  • FTPS: classic FTP with TLS encryption, port 21 (plus a range of data ports).
  • FTP: port 21, unencrypted. Avoid it on the internet.

“SFTP” is sometimes read as “Secure FTP”, but it is a different protocol from FTP.

Connect on the default port

sftp user@203.0.113.10

In FileZilla, use sftp://203.0.113.10 as the host and 22 as the port; in WinSCP, choose the SFTP protocol.

Connect when the server uses another port

Many servers move SSH to another port to reduce automated login attempts. Then SFTP moves with it. Note the capital -P for sftp and scp (lower-case -p means something else):

sftp -P 2222 user@203.0.113.10
scp -P 2222 backup.tar.gz user@203.0.113.10:/home/user/
ssh -p 2222 user@203.0.113.10         # ssh uses lower-case -p

We tested this on a server listening on ports 22 and 2222: sftp -P 2222 and scp -P 2222 both worked, and a wrong port answered Connection refused. More clients: connect to SSH on a different port.

Change the SSH and SFTP port on your server

Changing the port changes it for SSH and SFTP together. Keep port 22 open until the new port works, and open the new port in the firewall first. On AlmaLinux and Rocky Linux with SELinux enforcing, the new port must also be labelled for SSH (semanage port -a -t ssh_port_t -p tcp 2222). The full safe procedure: change the default SSH port safely.

Check which port your server uses

sudo sshd -T | grep -E "^port"
sudo ss -ltnp | grep sshd

Common errors

  • Connection refused: nothing listens on that port (wrong port, or SSH not running).
  • Connection timed out: a firewall drops the connection.
  • Permission denied (publickey): the server only accepts SSH keys; add your key or use the right one.

Using SFTP day to day: transfer files with SFTP. On cPanel hosting, SSH access and its port are shown in cPanel or given by support.

Ucartz services for this topic

Was this answer helpful? 0 Users Found This Useful (0 Votes)