To create an SSH key. go to your Linux machine and type:
ssh-keygen -t ed25519 -C "<comment>"
For the ‘
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
id_ed25519.pub
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:
-----BEGIN OPENSSH PRIVATE KEY-----
b3Blb************************************************************2gtZW
QyNTU************************************************************MLaqv
zAAAA************************************************************+TzAw
AAAEA************************************************************bwqPC
EA4yn**********************************CAwQ=
-----END OPENSSH PRIVATE KEY-----
id_ed25519.pub - The public key has the extension '.pub', is named 'id_ed25519.pub' 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: https://docs.gitlab.com/ee/user/ssh.html