Linux Server Access Using SSH Key without Password
Generating SSH keys allow you to log in to your Hostway server without the need to enter a password. You can generate SSH keys and install them on the remote server by following the directions in this article.
To complete this task, you will have to generate an SSH Key pair (private and public key) and copy the SSH public key to the remote server.
Generate an SSH Key pair on your local computer:
1 |
In your local computer, enter the following command in terminal:
ssh-keygen -t rsa |
2 |
Press enter to choose the default location of the newly created ssh keys. |
3 |
Enter the optional passphrase to secure your SSH key with a password, or press enter twice to skip the passphrase step.
You now have a private key in ~/.ssh/id_rsa and a public key in ~/.ssh/id_rsa.pub. If you used the optional passphrase, you will be required to enter it.
Copy the public key from your local computer to the remote server. Typically, the public key will be saved in ~/.ssh/authorized_keys on the remote server. For example, if you are setting up keys for the root user, the public key will be saved to /root/.ssh/authorized_keys. |
Copy the SSH public key to the remote server:
1 |
Execute the following command from the remote server:
vim /root/.ssh/authorized_keys |
2 |
Open a text editor, such as vim. In vim, press “I” to enter insert mode, then paste the public key you created into the authorized_keys file. |
3 |
Press :WQ to save your changes and exit vim. |
4 |
You should now be able to ssh into the remote server without entering your root password. |
You may see an existing public key in the authorized_keys file on the remote server. Take extra care not to delete any of the existing public keys. Hostway may have a public key installed on your server so we can login when you open support tickets. |