GitHub SSH Settings for Secure Access
Table of Contents
See also: Connecting to GitHub with SSH - GitHub Docs
Setting Up SSH Keys for GitHub
Environment: Ubuntu 22.04 LTS
1. Check for existing SSH keys
ls -al ~/.ssh
If you see files like id_rsa
and id_rsa.pub
, you already have SSH keys. If not, proceed to the next step.
2. Generate a new SSH key pair
ssh-keygen -t ed25519 -C "your_email@example.com"
You can only enter without input something to the interactive prompts like below:
Enter file in which to save the key:
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
3. Copy the public key to your clipboard
cat ~/.ssh/id_ed25519.pub
4. Add the SSH key to your GitHub account
- Go to Github > Settings > SSH and GPG keys > New SSH key
- Paste the copied public key into the “Key” field and give it a title.
5. Test the SSH connection
ssh -T git@github.com
You should see a message like:
Hi username! You've successfully authenticated, but GitHub does not provide shell access.