How to generate a SSH key on Linux Mint 21 vanessa or any other Ubuntu-based Linux distribution via the terminal emulator?

Revisited and updated on October 1st, 2023


SSH keys

SSH keys, short for Secure Shell keys, are a pair of cryptographic keys used in secure communication between two computers over a network, typically the internet.

They are commonly used to authenticate and secure remote connections to servers, systems, or other devices. SSH keys consist of two parts: public key and private key.


Note

My articles are constantly evolving, and I welcome any feedback, corrections, broken links, or suggestions you may have. Please don't hesitate to share them with me, and I'll be grateful for your input.

Give me a shout or add me:


Let's get down to business

shall we?

The-office GIFs - Get the best GIF on GIPHY


Check your OS

This step is just to make sure you have Linux Mint or a **Ubuntu-**based Linux distribution.

cat /etc/os-release
lsb_release -a
uname -a

Output


Generate SSH-key

ssh-keygen -t ed25519 -C "your email"

Replace "your email" with your actual email address.

Output

The ssh-keygen is a command-line utility that is used to generate an SSH key pair using the Ed25519 algorithm.

The -t flag specifies the type of key to create, key algorithm to use, and in this case, ed25519 indicates the Ed25519 algorithm.

The -C parameter provides a comment (usually your email address) to help you identify the key later.


Enter file

You can choose the path and filename.

If you just want to use the default name, press Enter, otherwise, provide the name/path of the file.

Enter file in which to save the key (/home/elitebughunter/.ssh/id_ed25519): /home/elitebughunter/.ssh/ssh_key_mdt

Output

elitebughunter@elitebughunter-linux-mint:~$ ssh-keygen -t ed25519 -C "Linux Mint"
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/elitebughunter/.ssh/id_ed25519): /home/elitebughunter/.ssh/ssh_key_mdt
Created directory '/home/elitebughunter/.ssh'.

Enter passphrase

If you don't want to provide a password, just press Enter

Created directory '/home/elitebughunter/.ssh'.
Enter passphrase (empty for no passphrase):

Output

elitebughunter@elitebughunter-linux-mint:~$ ssh-keygen -t ed25519 -C "Linux Mint"
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/elitebughunter/.ssh/id_ed25519): /home/elitebughunter/.ssh/ssh_key_mdt
Created directory '/home/elitebughunter/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/elitebughunter/.ssh/ssh_key_mdt
Your public key has been saved in /home/elitebughunter/.ssh/ssh_key_mdt.pub

Result


List all your ssh keys

ls ~/.ssh/

Tell SSH-agent

ssh-agent is a program that acts as a background agent to store and manage your SSH private keys.

It is commonly used on Unix-like operating systems, including Linux and macOS, to facilitate secure and convenient SSH key-based authentication.

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/<personal_key>

The ssh-add command alone should work for adding your SSH private key to the agent.

Just replace <personal_key> with the actual filename of your SSH private key.

With a ssh key called linux_mint_ebh_ssh_key, take a look at how it's going to become:

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/linux_mint_ebh_ssh_key

Output


Check your recently created keys

cat ~/.ssh/<personal_key>.pub

Just replace <personal_key> with the actual filename of your SSH private key.

Output

ssh-ed25519 AAZACZNzaZ1lZZI1NZE5ZAAAIOj3BR10R5aZetC7+EY4OIOZuwunQaZww9kxZWdwaZZZ youremail@outlook.com.br

Done


Celebrate

You've made it!

The Office GIF - The Office Happy - Discover & Share GIFs


Let's become friends


Final thoughts

I hope this article has been helpful to you. Please feel free to reach out if you have any questions. Your thoughts, suggestions, and corrections are more than welcome.

By the way, don't hesitate to drop your suggestions for new blog articles.

I look forward to seeing you next time.