Linux

How To Set Up Linux SSH Keys in Servers

We’re helping customers to increase the security of their F2H VPS Servers in several ways. First, we disable the root account on all instances by default. Next, during the instance install and reinstall we configure a user account. Finally, customers can also use an SSH key to access their instance. We’re going to set up SSH keys and use these keys to access instances without a password. This guide covers how to provide your SSH key in the Discovery control panel which will be installed when you reinstall your instance. And also how to set up a Linux SSH key and add your SSH keys to an already running instance.

Generate An SSH Keypair

SSH keys consist of a public key and a private key. You give out the public SSH key and keep the private SSH key secure. We advise storing your SSH keys in an external USB key or a service like Onedrive where you can sync the key over multiple devices. Do not lose your private SSH key. If you do, you could lose access to your instance. To generate your keypair. Login to your server and issue the ssh-keygen command.

ssh-keygen -t rsa

To generate your Linux SSH Key you will now be asked a number of questions;

  • Enter the file in which to save the key (/root/.ssh/id_rsa)
    • Press enter to store the key at the default location
  • Enter passphrase (empty for no passphrase)
    • If you want to enter a password each time you use your key. Enter it now.
Your public key has been saved in /root/.ssh/id_rsa.pub.
 The key fingerprint is:
 SHA256:MXLkhd/TKyX89UB4TmM6iXLaAKvILFNsFb1ZhipNuJM f2h@f2h-fr-x26.first2host.co.uk
 The key's randomart image is:
 +---[RSA 3072]----+
 |   ..o ….  .   |
 |  . o +G+.  . *  |
 | . % ..B=. + Z . |
 |  C o -ooo+ O = .|
 | = + .  Z*   * +.|
 |o - .   . . . o .|
 | o           .   |
 |                 |
 |                 |
 +----[SHA256]-----+

You will see the SSH key has been generated. In our example the default location /root/.ssh/ stores both the private SSH key and the public SSH key. To list your public key issue the below command. Remember to update the location if you choose a custom one above.

cat /root/.ssh/id_rsa.pub

Set Up SSH Keys On New Instances

If you are ordering a new NVMe VPS Server or reinstalling your current instance, you can supply your public key so it can be configured during setup. To supply your SSH key on a

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button