Category Archives: GitHub

How to Push to GitHub with SSH Configuration

Recently I came across a ProxyPool repo, which is a dynamic proxy pool used for web crawling. It is useful for me, so I think I can contribute my effort to benefit others. After adding some other free proxy service providers I found, I need to push my changes to my forked repo on GitHub.com.

I prefer using SSH for convenience and security, so I don’t have to type in my username and password every time. I read about GitHub tutorial on Connecting to GitHub with SSH, and some other sources like Push to github without password using ssh-key and Automatically use correct SSH key for remote Git repo. All the tutorials say to change repo’s remote url to this format:  git remote set-url origin git@github.com:<Username>/<Project>.git but my push fails, and ssh -T git@github.com gives Permission denied (publickey) error. Thankfully  ssh -vvv git@github.com shows some interesting hints:

It seems that with the aforementioned configuration git does not read my /Users/username/.ssh/config file and will only look for ssh keys with default names, i.e. id_*. I have multiple ssh keys for logging in to my VPS servers, and I rename all the keys accordingly, including this github key pairs. I also create an entry for each server in /Users/username/.ssh/config file like

so a simple command like ssh digitalocean will log me into the server. Then how to tell git to look for a Host entry instead? Here is the working remote url format on my machine: git remote set-url origin <Host>:<Username>/<Project>.git, therefore ssh authentication test command changes to  ssh -T github