Configuring private keys for ssh access

(On Mac OS X) – This assumes you have already downloaded your priviate keys to your desktop

There are 2 keys, one private and one public (this one has a .pub extension). Using Terminal, move your downloaded keys to your .ssh folder: for each file, type

mv Desktop/{name of key file} ~/.ssh/

Give your keys the proper names:

cd ~/.ssh/
mv {name of private key} id_rsa
mv {name of public key}

The private key should have readonly permissions:

chmod 400 ~/.ssh/id_rsa

So now you can login to the server. To simplify the process, you also create a text file ~/.ssh/config , where you can set three lines for ssh login info for your simple ssh use. To create the file, type:

vim ~/.ssh/config

Press ‘I’ (capital i) to go into ‘edit mode’, and then the following 3 lines (using the example of our Vasudeva Server servers:)

Host {server-name}
Port {port-number}
User {user-name}

Where {server-name} is the name of our server in lower case, {port-number} is the port we use to connect (for security reasons this is very often changed from the default port 22) and {user-name} is your user name to access the server. When you are finished, press escape (to exit edit mode) and then ‘ZZ’ (to exit and save changes)

After you have done that, you can try to log in using the command

ssh {server-name}

Another tip…

You can also create a simple alias for the server name by adding a line to your /etc/hosts file

{server-ip} {server-name} {server-name}

So a example for a hypothetical server located at ip address would be antara

This means that when accessing our servers, you can simply type

ssh {server-name}

without the at the end.