SSH keys allow connections using SSH without using the system user's password. Git platforms often allow the use of SSH keys to authenticate with private repositories.
- Log into SSH as the user you are generating the SSH key for
- Run the ssh-keygen command to generate an SSH key
ssh-keygen -t ed25519 -C "email@example.com DAY-MONTH-YEAR" -f ~/.ssh/my_key
- The -C flag specifies a comment to add to your public key. It is common practice to put your email address and the date as the comment. You may put any string as the comment, or omit it entirely.
- The -f flag determines what name will be used for your private and public keys. If you omit the -f flag entirely, your keys will be created at ~/.ssh/id_ed25519 and ~/.ssh/id_ed25519.pub. When specifying the -f flag, there is no need to specify the public key name as it will always be the same name as the private key, but with .pub appended to the end.