Tuesday, September 20, 2011

Runnning SSH on a non-standard port

The default port for SSH connection is 22. However some servers change the default port to others, for example 22222, for security reasons. Here I list some common commands to deal with non-standard SSH port.

Suppose you have a SSH server ssh.example.edu with ssh port number 22222.

To copy your ssh public key to the server, run:
ssh-copy-id '-p 22222 jon@ssh.example.edu'
Note the single quote is necessary.

To log in to the SSH server, run
ssh -p 22222 jon@ssh.example.edu 
 To copy files between your local machine and the server with scp, run
scp -P 22222 local-files jon@ssh.example.edu:~
 Note the "-P" option is capitalised.

References:
1. http://www.itworld.com/nls_unixssh0500506
2. http://mikegerwitz.com/2009/10/07/ssh-copy-id-and-sshd-port/


No comments: