DEV Community


Posted on


Generate and register an SSH key pair to log into an SSH server

The command ssh-keygen can be used to create an SSH key pair that is used to authenticate oneself. SSH supports a variety of authentication schemes, including the public-key system (

This article is a summary of an article found on Medium, which is written by Risan Bagja Pradana.

There are different algorithms for generating a key pair that SSH supports. The EdDSA algorithm is most recommended. The SSH term (or variant) for the algorithm is "Ed25519" (Pradana).

Among Pradana's recommended options (Pradana), one seems essential: The t option, which specifies the algorithm used to generate the key pair. So, for example, using the t option, the following command can be used to generate a key pair: ssh-keygen -t ed25519 (Pradana).

After generating the key pair, it is essential that we register the key pair with the SSH Agent. The Agent must first be running. And then, we use either of the following commands to add our new pair (Pradana):

ssh-add ~/.ssh/id_ed25519 # new pair, OR
ssh-add                   # all existing keys

Lastly, we must register the public key with the server we intend to connect to. Use the following command: ssh -i ~/.ssh/id_ed25519 username@server (Pradana).

More information can be obtained in the cited article by Pradana. It is a Medium article, but it is not a "Premium" article.

Top comments (0)

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git