How to change to using SSH over HTTP Authentication for GitHub
If you use GitHub and get sick of using your password for authentication, there is another way to push to your remotes; SSH!
The process is as follows;
- Find or generate your SSH key
- Copy your public key to the GitHub web interface under Settings > SSH & GPG Keys
- Remove or add your old git remote
- Push without passwords :D
In depth steps
Find or generate your SSH Key
Most people save their keys into a hidden folder in their home directory called
To see if you’ve got any keys in there, run the command
ls ~/.ssh to list out the files you’ve got in that folder.
If you don’t see any files or an error saying the folder doesn’t exist you need to generate a key. This is made easy through a tool called ssh-keygen.
ssh-keygen and follow the steps to generate your own private key pair.
Copy your public key to the GitHub web interface under Settings > SSH & GPG Keys
Now you need to make GitHub aware of that SSH key. To do so go to the site in your browser, click your user profile and go to Settings.
- Under settings you can click the SSH & GPG keys section. Click “New SSH Key”
- Open your terminal and enter
cat ~/.ssh/id_rsa.pubor whatever you called you keypair.
COPY THE FILE WITH THE .PUB FILE EXTENSION ONLY
You don’t want a copy of your public key on the internet. Guard it like you would guard your password, that means don’t upload it anywhere public!
- Save the key
Remove or add your old git remote
Time to start using the SSH method to push your code.
If you have an existing codebase you want to use, you might need to remove the HTTP git remote url. To do that open your terminal and;
- cd to your codebase
git remote -v
- If nothing comes out at this point you are fine, else;
git remote remove origin
- Now to add the SSH url;
git remote add origin <SSH_URL>(You will find this in GitHub by clicking “Clone or Download” then “Use SSH”
Push without passwords :D
Now you’ve added the SSH URL you can push your codebase to your remote the way you normally would (
git push origin HEAD)
And that’s it!
If you see any mistakes or want any explanations of the topic of this post, get me on Twitter @afallon02 or email me at email@example.com