You can use user and password based authentication to push git changes to GitHub. But it is cumbersome to type user and password with every push. A better alternative is to use ssh key for authentication while pushing. Here are steps to setup ssh key based password less authentication with GitHub.
Create a ssh public and private keys
First create a public/private key for authentication. You can create ssh key pair (without passphrase) as mentioned in the linked tutorial. You can use the following location for two generated files.
Add public keys to GitHub
- Goto GitHub settings page:
- Add you public keys to GitHub by copying content from
Once you add your public key, you should see it in the list of keys in your account.
GitHub config on you local machine
- First setup remote.origin.url using
$ git config remote.origin.url git+ssh://email@example.com/youriserid/repoid.git
Old : https://github.com/youriserid/repoid.git
Now add the following lines to you ~/.ssh/config to ssh that for github servers we want to use git key
Host github.com IdentityFile ~/.ssh/id_rsa.github
Test that you can ssh to github
$ ssh -T firstname.lastname@example.org Hi user1! You've successfully authenticated, but GitHub does not provide shell access.
Now make any test change and commit locally. To push to origin run the following and it should not ask for password.
$ git push origin master
To see all git config values and validate if remote.origin.url has been set
$ git config -l