SSH delivers a secure channel over an unsecured network in a client-server architecture, connecting an SSH client with an SSH server. Creating an SSH key set provides you with a public and a private key. You can place the public key on any server, and then unlock it by connecting to it with a client that already has the private key you created on it. When the SSH key sets match up, the system unlocks without the need for a password.
Information security starts with controlling access to systems and data. No control over access means no security, no privacy, and no reliability.
- Creating SSH Keys
- Adding SSH Keys to Your Server
- Adding Additional Authorized Keys to Your Server
- Removing Authorized Keys from Your Server
- Storing Your Public Keys in the OVH US Manager
Note: SSH keys created before November 7th, 2018 work solely for US data centers. To use a key viable for all data centers, create a new key.
Creating SSH Keys
On your Mac or Linux machine, open Terminal.
Note: If you are using a Windows OS to SSH into a server, you will need to download third-party software as Windows does not allow SSH by default.
Verify that you have a
.ssh folder in your
$HOME directory. If the folder does not exist, create it:
$ mkdir ~/.ssh
Change your working directory to the
.ssh directory and use the following command to generate an ED25519 SSH key pair:
$ ssh-keygen -t ed25519 -a 256
The "-t" in this command tells your computer what encryption type to use for the SSH key. If you would like to use a different encryption type, replace the "ed25519" with whichever encryption you choose. Please note that if you would like to store an SSH key in the OVH US Manager, you will only be able to use ED25519, RSA, or ECDSA encryption.
You will be prompted to enter a passphrase to password-protect your SSH key. This is entirely optional but recommended for added security. Your SSH keys will be created and stored in the
.ssh directory. In order to read your public key, use the following command:
$ cat ~/.ssh/id_ed25519.pub
Adding SSH Keys to Your Server
Navigate to your
$HOME directory and look for a .ssh. If one does not already exist, create it by entering the following:
$ mkdir ~/.ssh
Create a folder to store your authorized keys. To do this, open a file with the name
authorized_keys in a text editor of your choice (we'll use
vim). Navigate to the
.ssh directory that you just created and enter this command:
$ sudo vim ~/.ssh/authorized_keys
Copy and paste the public key which you created in the previous section into this new text file. Save the file and exit the text editor. Restart your server or restart OpenSSH using the following command:
$ sudo systemctl restart sshd
To test that your key has been set up properly, attempt to access your server via SSH using the following command, remembering to replace "IP_ADDRESSorHOSTNAME" with the IP address or hostname of the server you are trying to access:
Adding Additional Authorized Keys to Your Server
To add additional authorized SSH keys for additional users, follow this article again using the new user's
$HOME directory to create that user's unique key.
Removing Authorized Keys from Your Server
Storing Your Public Keys in the OVH US Manager
The OVH US Manager allows you to store any public key you create as long as those keys use one of the following encryption types: ED25519, RSA, or ECDSA.
To store your keys in the OVH US Manager, log in to the OVH US Manager and click on your name in the top-right corner of the screen. Select My account from the drop-down menu. Then, on the left-hand sidebar, click My SSH keys.
Next, click Add an SSH key and choose which service to attach it to. You will see the following popup window:
Enter an SSH Key name of your choice in the "ID" field. Copy and paste the full SSH public key in the "Key" field. Note that in order to store your key, you will need to specify your identifier after the pasted key. This is a requirement of the OVH US Manager. See the example format above. Click Confirm to store your public key.
SSH key pairs are important to ensuring the security of your server. While the steps you took using this article should be sufficient for most use cases, it is worth noting that OpenSSH can be configured to be more secure if that extra security is needed. Regardless of what your security needs are, they are too important to not use the strong layer of security which SSH keys provide to you.