I manage a lot of servers, login in quickly without having to look up passwords or remember which username it was should be simple, I’ll show you how simple it can get!.

Below I will give you some tips of how to improve your SSH workflow.

ssh-copy-id is great!

By using ssh-copy-id you connect to the server using secure keys instead of having to use a password.

The syntax of ssh-copy-id is the following: bash ssh-copy-id user@server.com

and then it will ask for the password.

it works by copying your public key from ~/.ssh/id_rsa.pub to the servers ~/.ssh/authorized_keys.

And when you then type ssh root@server.com it will first try to connect via secure keys which compares your private key ~/.ssh/id_rsa with the public key you copied with ssh-copy-id before falling back to using passwords.

Generate new key

You can generate your private and public key with the following command: bash ssh-keygen -t rsa -b 2048

Simplify further

Now it’s time to simplify the ssh command. We still need to specify the user and the host when we connect but by specifying this in the ssh config file we can do away with a lot of typing.

Open the file ~/.ssh/config and put the following in it:

# Stop timing out connections
ServerAliveInterval 300
ServerAliveCountMax 20

# Specify default user
User root

Host myalias
	HostName server.com
	User root

Host myalias2
	HostName server2.com
	User root2

The first is to stop OSX Lion from closing down the connection. (If you don´t specify this, you get Broken pipe syndrome)

I hope this will help you become a better unix hacker :)