In this article, we will explain how to add SSH keys to your GitHub Account.
Adding SSH keys to your GitHub account allows you to securely connect to repositories without entering your username and password each time.
Let us follow the guide:
- Open your terminal (Linux/macOS) or Git Bash (Windows).
- Run the following command to see if you already have an SSH key:
ls -al ~/.ssh - Look for files named ‘id_rsa.pub’ or ‘id_ed25519.pub’. If present, you can use them; otherwise, proceed to generate a new key.
- Generate a new SSH key by running:
ssh-keygen -t ed25519 -C “[email protected]”If your system doesn’t support ed25519, use:
ssh-keygen -t rsa -b 4096 -C “[email protected]” - When prompted to “Enter a file in which to save the key,” press Enter to accept the default.
- Add a passphrase if you want extra security (optional).
- Start the SSH agent by running:
eval “$(ssh-agent -s)” - Add your key to the agent:
ssh-add ~/.ssh/id_ed25519Replace ‘id_ed25519’ with your key filename if different.
- Copy your public key to the clipboard:
cat ~/.ssh/id_ed25519.pub - Copy the full output (starts with ssh-ed25519 or ssh-rsa).
- Log in to your GitHub account.
- Go to ‘Settings>SSH and GPG keys>New SSH key’.
- Give your key a descriptive Title (e.g., “Work Laptop”).
- Paste your public key into the ‘Key’ field.
- Click ‘Add SSH key’.
- Test your SSH connection by running:
ssh -T [email protected]You should see a message like:
Hi username! You’ve successfully authenticated, but GitHub does not provide shell access.
In this manner, adding SSH keys to GitHub improves security and makes working with repositories faster and more convenient. Make sure to keep your private keys safe and never share them.
Visit our Knowledge Base to learn how to change the SSH Port in Red Hat Enterprise Linux.