1. Home
  2. Cloud
  3. Create SSH key pairs

Create SSH key pairs

SSH (Secure Shell) is used to securely connect to remote servers. SSH key pairs consist of two parts: a private key that you keep secure on your local computer and a public key that you share with the servers you want to connect to.

If you want to create a key pair and use it for your web hosting or managed service, we have a guide on how to create it via cpanel.

Execution

Here are the steps to create an SSH key pair in Linux.

Open the terminal

To start, open a terminal on your Linux computer. You can use programs like Terminal, Console, or xterm, depending on your Linux distribution.

Create SSH key pairs

Use the command ssh-keygen to create an SSH key pair. If you don’t set any flags, the command will use the default settings, including the RSA key type, and save the keys in your home folder in a subfolder called .ssh. You can also specify another location to save the keys if you wish.

ssh-keygen

If you want to use a different key type, like Ed25519 (recommended), you can use the -t flag:

ssh-keygen -t ed25519

Enter a file to save the key (optional)

By default, ssh-keygen stores the keys in your home folder in a subfolder called .ssh with the names id_rsa (private key) and id_rsa.pub (public key). If you want to specify a different file to save the keys, you can use the -f flag:

ssh-keygen -f /desired/path/to/key file

You can also protect your private key with a passphrase for extra security. This means that you have to enter the passphrase every time you use your private key. If you want to add a passphrase, enter it when prompted.

Complete the process

After entering all the desired settings, ssh-keygen will create your SSH key pair. You will receive a confirmation that the key pair has been created and where it has been saved.

Now you have successfully created an SSH key pair in Linux. You can copy the public key (id_rsa.pub or whatever you have named it) and use it to authenticate yourself on a remote server. You should protect your private key carefully and not share it with anyone.

Was this article helpful?

Related Articles