SSH keys are fairly simple to setup, especially when using the native terminal applications available in either Linux or Mac OSX. Here's how!
In terminal, type the following command:
This will ask you a few questions, the defaults for which are just fine, no passcode is necessary. This will generate a key in the ~/.ssh/ directory. Now we just need to get that file up to the server.
You can do this using scp, or rsync. Below is an example of a properly formatted rsync command, be sure to replace username with the username intended to access the server and the IP address with the address of your server:
In the event your server uses a non-standard port for ssh, you can specify this inside the quotes around ssh. Here is an example for port 2222, the default port for HostGator shared servers:
Once running this command you will be prompted for your root password, as rsync creates an SSH connection to transfer the file to your server. Once the password is entered the file will be synced up to the server.
Now we want to ensure that all is well on the recipient server. SSH into your server and run the following commands:
chmod 600 ~/.ssh/authorized_keys
chown username. ~/.ssh/authorized_keys
That's it! You should be all set! Now to access your server you need only do the following:
The server should automatically accept your key and log you into shell as the specified user.