Keyless SSH Connections on custom ports

If you often ssh into different boxes around the place and get fed up with constantly typing your passwords in, there is a very easy way to setup public keys that make this repetitive task a thing of the past.

Note: There are loads of posts on the net of how to do this but as a general rule the first thing i do after installing openssh is change the default port it listens on, this is one more barrier for brute force attackers to overcome. I have found not many tutes on show you how to complete the final stage (copying  your public key to the remote server) but using this different ssh port. Here’s how you do it:

1. Create your key (if you dont already have one)

ssh-keygen -t rsa

Just press enter to all prompts leaving passwords blank.

2. Copy your key to your  remote server

Using standard ssh port:

ssh-copy-id -i ~/.ssh/ username@server

Using a non-standard port (in this case 1234)

ssh-copy-id -i ~/.ssh/ ‘-p 1234 username@server’

Thats it! You should now be enjoying password-less connection to your boxes. Like i said this is not a unique post but ive not seen many using custom ssh ports so hope it helps someone!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s