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.
Open your terminal and type command below.
ssh-keygen -t ed25519 -C "email@example.com"
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.
Save the key and you're ready to push your changes to GitHub using SSH connection. Congrats! 🥳