DEV Community

Clever Lopes
Clever Lopes

Posted on • Updated on

Fast guide, creating a ssh key pair for the user in Linux

Pre reqs

For this very short tutorial, you need to have installed the ssh client and server on your linux.
To install on Ubuntu:
$ sudo apt install openssh-client
$ sudo apt install openssh-server

On Arch
$ yay -S openssh or $ sudo pacman -S openssh

Getting Started

To create your key pair run this command:
$ ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -C "{your_email}"

After this will appear a message to enter a passphrase like this:
Enter passphrase (empty for no passphrase):

You can just press Enter or write your passphrase and confirm.

Return of the commands example

To get your pub key type:
$ cat ~/.ssh/id_ed25519.pub

Get pub key return example

Now you can copy your pub key and register on the ssh client of the service you want, like Github or Amazon.

So you don't have to type the passphrase all the time, your machine needs to have the ssh-agent service. You check if is running with this command:
$ eval "$(ssh-agent -s)"
The command will return the agent pid of the process.

If it is running, you can add your new key to the agent, just type:
$ ssh-add ~/.ssh/id_ed25519.
Then it only will ask for your passphrase once.

Well done! Now you're a cryptographically identifiable citizen in our society.

Top comments (0)