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.
How 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.
How to create an SSH key
For creating an SSH key in Linux following these steps:
1) Check for existing SSH keys
Run this command in your terminal to check your existing SSH keys:
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:
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 the whole information about your generated keys you can use the following command:
That’s It. Hope you enjoy this article about how to generate SSH key pair in Linux.
We will publish another article for use ssh-key for connecting to Linux.
Stay with us for more articles.