I'm trying to automate logins to GitHub using a private key, so that I can do "git pull/add/commit/push" from a BASH script. If I put this in ~/.ssh/config, it works:
Hostname github.com
User git
IdentityFile ~/.ssh/mygitkey.pem
Unfortunately, this causes all SSH connections to be routed to Github.com, which I don't want.
So I tried this:
Host GitHub
Hostname github.com
User git
IdentityFile ~/.ssh/mygitkey.pem
But this causes the "user" and "identityFile" options to be ignored when connecting to GitHub.
You probably want something like this:
(Possibly the
User
if it serves a purpose for you, but the remotes in your repositories presumably already say[email protected]
, which would make it pointless to specify theUser
here too)The config in the question looks like it should technically work, but you would have to change all references (like the remotes in your repositories) from
github.com
toGitHub
.