What Are the Benefits of Key Based Authentication?
SSH (Secure SHELL) is an open source — and most trusted – network protocol used for logging into servers remotely, allowing the execution of commands and programs as though you were at the server itself. It can also be used to transfer files between computers over the network using the Secure Copy (SCP) protocol.
SSH keys are a way to further secure your server against malicious activities directed at trying to SSH into your server by providing a level of authorization that can only be fulfilled by those who have ownership to the private key associated with the public key on the server. An unwanted visitor may be able to get access to the server’s public key, but without the associated private key they will be unable to gain access to the server, even if they know the password.
With an SSH key set up, you can also safely log in to your server without any need of a password at all, as the server will require the connecting computer to have the private key associated to the server’s public key to connect. This means that with or without the password, only users with the private key generated with the public key can gain access.
How Do I Setup Key Based Authentication?
The following guide will help you create a public / private key pair, get them installed and ready to use for your SSH server;
Local Linux/Mac OS to Remote Linux Server (Cloud/Dedicated)
Step One: Enter the following command locally
$ ssh-keygen -t rsa
This will generate two files in your hidden ~/.ssh directory
- id_rsa – your private key
- id_rsa.pub – your public key
Step Two: Choose whether or not you want a password upon setup; Hit “Enter” to set no password, otherwise type the password to be used and then hit “Enter” afterwards.
Step Three: Set the permissions on your private keys
chmod 700 ~/.shh chmod 600 ~/.ssh/id_rsa
Step Four: Copy and install your public key (id_rsa.pub) to the server’s authorized_keys list
cat ~/.ssh/id_rsa.pub > ~/.ssh/authorized_keys
Step Five: Set your server permissions
chmod 600 ~/.ssh/authorized_keys
Step Six: Set proper SELinux context
restorecon -Rv ~/.shh
SSH Key through PuTTY
If you wish to know how to set up an SSH key for your Cloud VPS services, we have provided step-by-step instructions for your convenience at our Setting Up an SSH Key through PuTTY guide. If setting up the SSH Key through PuTTY, you will need to upload the public key to the server. (Commonly done through FTP or SFTP)
- Guide to Connecting to Your Server via SSH – Guide on how to use PuTTY or other similar SSH Applications to connect to your server.
- SSH Key Management – More information on how to manage SSH Keys for Cloud Servers
If you should have any questions or would like assistance, do feel free to contact us through Live Chat, on our Phones, or by submitting a ticket with our Technical Support team.