View all posts

How to create SSH keys

QuickHostUK uses key-based authentication for SSH. It has proven to be more secure than traditional username and password authentication.

The SSH key pair can be generated directly in your hosting panel, or you can generate the keys yourself and upload the public one to your account.

The ssh-keygen command can be used to generate SSH keys under Linux.

Simply follow these steps:

First, log in to your server via SSH as the root user.

ssh root@server-ip

Type in the following command:

ssh-keygen -t rsa

Next, you will have to type in the location of the file where you would like to save the private key.

Enter file in which to save the key (/home/youruser/.ssh/id_rsa):

Note: the public key is saved in the same location as the private key with the same file name, but with the .pub extension.

Hit enter to use the default suggested location which is usually /home/youruser/.ssh/id_rsa .

Next, you will be prompted for a password. This password is required to use the private key. So you would need to enter it to connect via SSH, for example.

Hit enter for no password.

Enter passphrase (empty for no passphrase):

The process of generating key pairs would look like this:

ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/quickhostuk/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/quickhostuk/.ssh/id_rsa.
Your public key has been saved in /home/quickhostuk/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:....WZho quickhostuk@srv.quickhost.uk
The key's randomart image is:
+---[RSA 2048]----+
|B==. ..o..       |
|*oo+ .+ + o      |
|oo+ o..* +       |
| *.o o+ .        |
|o E.+o. S        |
| * =o. .         |
|+ o . o          |
|o+.  o .         |
|oo..  .          |
+----[SHA256]-----+

The private key will go into /home/youruser/.ssh/id_rsa file and the public key into /home/youruser/.ssh/id_rsa.pub file.

To use this key for SSH access on a remote system, you can then copy the key to the remote system likes so:

ssh-copy-id root@1.2.3.4
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/quickhostuk/.ssh/id_rsa.pub"
The authenticity of host 'srv.quickhost.uk (1.2.3.4)' can't be established.
ECDSA key fingerprint is SHA256:....ANIc.
ECDSA key fingerprint is MD5:......43:60.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys

root@srv.quickhost.uk's password:

You should now be able to SSH to the remote system without a password from now on.

Related Articles...

Install LAMP

How to install LAMP Stack on Ubuntu 20.04

What is LAMP? The LAMP acronym stands for Linux, Apache, MariaDB/MySQL, and PHP, all of which are free and open source. It is the most commonly used software stack for dynamic websites and web applications. The operating system is Linux, the... Read more

This website uses cookies

We use cookies for the analysis of our visitor data, to improve our website, and to give you a great website experience. For more information about the cookies we use, please see our cookie policy.