Create an SSH key with ssh-keygen (id_ed25519)

To create an SSH key. go to your Linux machine and type:

ssh-keygen -t ed25519 -C "<comment>"

For the ‘’ part you can use anything, but it might be more useful to create little identifiers like ‘laptop-win’/’laptop-wsl’/’ubuntu-server-01’/etc, so you can easily see what key you are dealing with later down the road.

The ‘ssh-keygen’ command will ask you for a location to store the files, and for a passphrase. Just keep hitting Enter for the defaults if you are not sure. (A passphrase is more secure, but will require you to enter it when connecting to a server, so it’s easier/quicker to not have it, choose for yourself).

This command above will generate 2 files, a private key and a public key. They belong to each other.


id_ed25519 - The private key must remain private at all times! Don't copy it or anything, just keep it where it is and don't touch it ever again. The keys are there to identify 1 machine only, so 2 machines must not ever have the same keys. 1 machine = 1 private key + 1 public key. If you think your private key is compromised somehow, just remove the private+public keys and generate a new pair! The private key will look something like this:

-----END OPENSSH PRIVATE KEY----- - The public key has the extension '.pub', is named '' by default. For things like access to servers/github/gitlab etc you only need to give out your public key. It looks something like this:

ssh-ed25519 AAAAC3NzaC1lZD******************4iqj7l1Aj5PMD <comment>

To access an external server, this public key of yours needs to be in the 'authorized_keys' file on that server.

More info: