GitHub is my favorite cloud repository and I've used it for a long time. It allows use to collaborate with other developers and also integrates our project with awesome tools like Travis CI, Heroku, etc to make our project easy to manage and deploy.
To connect with GitHub and doing some actions like
pull, we have two options. Via HTTPS and SSH.
HTTPS using HTTP protocol to transfer changes to GitHub and requires us to input our username and password every time we do those actions.
While SSH using SSH protocol to transfer changes to GitHub and requires us to input our passphrase (if your provide it) and it more secure.
This article will guide you to add SSH-Key on your GitHub account. Let's try it out!
- SSH agent (installed on your computer)
- GitHub account (sign-up here)
In this article I use Ubuntu 20.04 and I will not cover about how to install SSH agent if you are using Windows. You can search it on google and back here again.
If you are using Linux or Mac OS, then you're all set because they have SSH installed.
1. Generate SSH-Key
Open your terminal and type command below.
ssh-keygen -t ed25519 -C "firstname.lastname@example.org"
You will asked where you want to put your key. If you not sure, just leave it and enter.
Enter file in which to save the key (/home/you/.ssh/id_rsa):
If you already have any SSH-Key with same name, it will override the old SSH-Key.
After that, you will asked about passphrase. Passphrase is like password. It will prompt you to input your passphrase whenever you want to connect with another host.
Enter passphrase (empty for no passphrase): [Type a passphrase] Enter same passphrase again: [Type passphrase again]
Copy our public key. You can use tools like
xclip. You can also use
cat command and copy the key manually.
2. Login to GitHub and go to settings
Login to your GitHub account. You will see your profile photo at the right top corner. Click it and go to settings.
3. Go to SSH and GPG keys setting
On left menu, click SSH and GPG keys.
4. Add new SSH-Key
On this page you will see all of your SSH-Keys. To add new one, click the
New SSH key button.
Fill the title and key. Remember to copy the public key on your local computer. Not the private key.
Save the key and you're ready to push your changes to GitHub using SSH connection. Congrats! 🥳
Top comments (0)