Step 1. Generate a SSH key.
If you are windows user, you can use PuTTygen which comes along with putty.
Click Generate. Then follow the instruction. At the end, you should have both public key and private key.
Save private key at a safe location. Because you will need it whenever you login. Copy the public key in the text box and you are ready to set up your server.
Step 2. Import key to server
Log into the server terminal and create a directory.
mkdir -p ~/.ssh
Add your SSH key to an
authorized_keys file in this directory.
At the open file, paste the public key you copy from PuTTygen and save. Or you can use the following command without open the file.
echo "xxxxxx== username@your_ip_address" >> ~/.ssh/authorized_keys
Note that 'xxxxx' is your public key and substitute username /ip address with your own.
Now you have a key saved in your server.
Step 3. Grant proper permission
Last thing you need to do is to update permissions on some of the files.
authorized_keys. Otherwise you won't be able to log into the server.
chmod -R go= ~/.ssh
chown -R $USER:$USER ~/.ssh
Also change user info. Now you can log in via the key without using a password. To make your server more secure, you may want to disable password login.
To do so, go to
Change following value to no
Save and you are all set.