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:
1 2 3 4 5 6 7 8 9 10 |
...... debug1: Trying private key: /Users/username/.ssh/id_rsa debug3: no such identity: /Users/username/.ssh/id_rsa: No such file or directory debug1: Trying private key: /Users/username/.ssh/id_dsa debug3: no such identity: /Users/username/.ssh/id_dsa: No such file or directory debug1: Trying private key: /Users/username/.ssh/id_ecdsa debug3: no such identity: /Users/username/.ssh/id_ecdsa: No such file or directory debug1: Trying private key: /Users/username/.ssh/id_ed25519 debug3: no such identity: /Users/username/.ssh/id_ed25519: No such file or directory ...... |
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
1 2 3 4 5 |
Host github Hostname github.com Port 22 User git IdentityFile ~/.ssh/github |
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