How to use your SSH key to push on Github

You want to configure your computer to be able to pull, push and fetch repositories without asking you to enter your username/password? You have to configure some little things that we did not set them in the beginning.

We need an SSH Key first!

First you have to provide a SSH key(I don’t know what SSH is), to generate a new key you can follow these commands (If you already have one skip this):

ssh-keygen -t rsa -b 4096 -C ""

This command will generate a new SSH public and private key. You should NOT send your private key to anyone !!
If you take a look to the .ssh folder you will find two files id_rsa and (public).
Check if the SSH agent is running, this should return a PID:

eval $(ssh-agent -s)

To add the new generated key to the SSH agent you need this command:

ssh-add ~/.ssh/id_rsa

Configure your Github

Assuming that you already have a Github account. After copying your public key (the content of, go to setting > SSH and GPG keys > New SSH key and then copy/paste your public key. Then, you need to add Github host to SSH agent by running this command:

ssh-add -T

Check if you cloned a repository using a SSH and not by HTTPS protocol in this file .git/config:

	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[remote "origin"]
	url = # change it to
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "develop"]
	remote = origin
	merge = refs/heads/develop


You Might Also Like

Leave a Reply