Generate SSH key pairs in Linux

In this article, we want to teach you how to generate SSH key pairs in Linux. You can generate SSH keys in all distributions like Centos 7, Ubuntu, Debian, Fedora, etc.

Steps To generate SSH key pairs in Linux

First of all, let’s see what the SSH key pair is.

What are SSH key pairs?

SSH key pairs are two cryptographically secure keys that can be used to authenticate a client to an SSH server. Each key pair consists of a public key and a private key. As the SSH protocol is widely used for communication in cloud services, network environments, file transfer tools, configuration management tools, and other computer-dependent services, most organizations use SSH keys to authenticate identity and protect those services from unintended use or malicious attacks.

Create an SSH key

For creating an SSH key in Linux follow these steps:

1) Check for existing SSH keys

Run this command in your terminal to check your existing SSH keys:

cd ~/.ssh

If you see “no such file or directory”, it means that there aren’t any existing keys.
So check to see if you have a key already with this command:

ls id_*

2) Backup old SSH keys

If you have existing keys but don’t want to use them you can backup them by the following command:

# mkdir key_backup
# cp id_rsa* key_backup

3) Generate a new key

If you don’t have an existing SSH key you can easily generate a new key by following these steps:

• For generating public/private key pairs run this command in your terminal:


• Just press <Enter> to accept the default location and file name. If the .ssh directory doesn’t exist, the system creates one for you.
• Enter, and re-enter, a passphrase when prompted.
• It’s done; your keys are generated now.

Note: If you want to see all the information about your generated keys you can use the following command:



That’s It. I hope you enjoy this article, Generate SSH key pairs in Linux.

Also, you may be like these articles on the Orcacore website:

Enable and Configure SSH on Ubuntu 22.04

Enable and Configure SSH on Debian 11


Please enter your comment!
Please enter your name here

Latest Articles


Most Popular