If you want to setup SSH trust between your local development machine & a project hosted on Github, please follow the process below & you will be able to setup it. This process is tested on Fedora/ Ubuntu but it should work on any Linux based OS. On your local Linux machine please generate a RSA SSH Public key if already not generated. You can check it by going to .ssh folder of home directory. If not please execute the below command and follow the instructions:
ssh-keygen -t rsa
After you are done with generating SSH key Please execute the below two commands on terminal.
eval "$(ssh-agent -s)"
Now copy the content of id_rsa.pub to clipboard.
Open this URL in your browser : https://github.com/settings/ssh , you will see there are two options are there to be filled.
Title : <Your Title> you can fill some meaningful title here. example : Shashank’s Fedora Laptop Key
Key : Paste the content of id_rsa.pub file & save it.
You can verify it by running below command on terminal.
It will show your github username with some other information. If not please check the steps above.
Now, goto your git project’s home directory and run below command:
git remote -v
Below result should be shown on Terminal.
origin https://github.com/USERNAME/PROJECTNAME.git (fetch)
origin https://github.com/USERNAME/PROJECTNAME.git (push)
Your fetch and push origin URL Will be listed. If it is a HTTPS URL change it by running,
git remote set-url origin firstname.lastname@example.org:USERNAME/PROJECTNAME.git
Verify it by running “git remote -v” again. You will get below result on terminal.
origin email@example.com:USERNAME/PROJECTNAME.git (fetch)
origin firstname.lastname@example.org:USERNAME/PROJECTNAME.git (push)
Now , goto your projects home and try to run git commands to Fetch/ Pull from origin it’ll work through SSH.
If you feel there is a better way to setup SSH on Github please leave a comment.