As you may have seen in your mail. Cloning a github repository with username and password will be removed later in 2021. As a developer it was a bit weird when you are used to a username and password in your terminal for all those years. If you are wondering what I mean, check this out https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/
Here is how it works on ubuntu 20.04
Create your key
- In your terminal type: ssh-keygen -t rsa -b 4096 -C “this is my awesome public and private key”.
- You will be asked to give it a name. For simplicity we keep it like it is, id_rsa
- If you really want it to be secure add a password for the key.
- When your are done you should have a id_rsa and a id_rsa.pub file
Add your key to the startup of your ssh client
- Lets add our key to the start-up when logging in
- In your terminal type: nano ~/.ssh/config
- add the following three lines at the end of this file
- Host github.com
- HostName github.com
- IdentityFile ~/.ssh/id_rsa
- After your are done the file will look like this.
- Make sure you reconnect you terminal.
Add your key to Github
- Now that we have our keys, let github know this key is allowed to clone stuff.
- Get the content of your id_rsa.pub file by typing in your terminal: cat id_rsa.pub
- Copy and paste that content as a new SSH key inside github keys tab and give it a name.
- After that hit the add SSH key button and your are done.
Cloning your repository
- now we are ready to clone our project without username and password:
- Type in your terminal: git clone git@github.com:username/repo.git dirname
- When your terminal tells you The authenticity of host ‘github.com (140.82.121.4)’ can’t be established. Type yes and press enter.
This works well, thank you so much!