SFTP Default Port 22
Generally, you can sftp from client to the server through its default port 22. But sometimes, system administrators only allow privileged users to use it, you might be assigned to connect to a different port.
Try the following syntax.
[root@localhost ~]# sftp [email protected]:229
Connecting to ftp.example.com...
ssh: connect to host ftp.example.com port 22: Connection timed out
Couldn't read packet: Connection reset by peer
sftp did not alert any syntax error, but it still connect to port 22.
SFTP Non-Default Port
After checking the manual of sftp, I got the answer in the manual:
[root@localhost ~]# man sftp
...
For example, to specify an alternate port use: sftp -oPort=24.
...
OK, let's try it.
[root@localhost ~]# sftp [email protected] -oPort=229
Connecting to ftp.example.com...
ssh: connect to host ftp.example.com port 22: Connection timed out
Couldn't read packet: Connection reset by peer
Not working, but how about switching places of the two arguments.
[root@localhost ~]# sftp -oPort=229 [email protected]
Connecting to ftp.example.com...
The authenticity of host ...
RSA key fingerprint is ...
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ...
[email protected]'s password:
sftp> pwd
Remote working directory: /home/user
Now, it's working. But I don't think sftp is smart.