Hi there, this is something that helps me out frequently so I wanted to share it with the community.
If you are at all security conscious, you will want to use public/private key authentication, instead of regular passwords, when authenticating to your servers.
This short guide will explain, quite simply, how to add your SSH private key to your server, so you can authenticate with your public key. This guide assumes you already have your public key to hand. I am using Debian 7, however it will work with many other popular distributions of Linux such as CentOS and Ubuntu.
1. Login to your server, and change to your home directory.
2. Create a new folder called .ssh.
3. Set the permissions on .ssh to 700.
chmod 700 .ssh
4. Change into that directory.
5. Create a new file called authorized_keys.
6. Set the permissions to 600 (many applications including OpenSSH will reject your key by default, if it’s accessible by other users).
chmod 600 authorized_keys
7. Open the file with a text editor (I use vi), and paste your keys in.
That’s it. Now disable password authentication in SSH to improve the security of your box.
Thanks for reading.
Here are all the commands together in-case you are want a quick copy and paste job:
cd ~ mkdir .ssh chmod 700 .ssh cd .ssh touch authorized_keys chmod 600 authorized_keys vi authorized_keys