How to generate SSH keys on Linux
I recently switched from Windows 11 back to PopOS Linux and decided to regenerate my SSH keys. I used Generating a new SSH key and adding it to the ssh-agent as a reference for these steps.
Here are the steps I followed:
1.0 Generate the SSH Key
I generated a new Ed25519 SSH key with a comment that includes my email:
ssh-keygen -t ed25519 -C "michael@michaelharley.net" -f ~/.ssh/id_ed25519_mbp_linux
2.0 Secure the Private SSH Key
I set the permissions of the private key to read-only for the owner:
chmod 400 ~/.ssh/id_ed25519_mbp_linux
Note: Using chmod 400
restricts the file to be readable only by you.
3.0 Start the ssh-agent
and Add Your SSH Key
First, ensure the ssh-agent
is running:
eval "$(ssh-agent -s)"
Then add your SSH key to the agent:
ssh-add ~/.ssh/id_ed25519_mbp_linux
4.0 Add Public SSH Key to Services
I added the new SSH key to the services I use.
4.1 Capsul
I want to use this new key to access the Capsul VPS that hosts my website:
ssh-copy-id cyberian@69.61.2.205
To verify, I SSH into the server and execute:
cat ~/.ssh/authorized_keys
4.2 Codeberg
Following Adding an SSH key to your account, I added the new key to my Codeberg account.
Verification:
Test the connection to Codeberg:
ssh -T git@codeberg.org
You should see a welcome message if the setup is correct.
5.0 Conclusion
That's it! These are the steps I used to regenerate my SSH keys and integrate them with my services on PopOS Linux. If you have any suggestions or if I missed anything, feel free to leave a comment below or reach out to me directly.