Reputation: 3442
I have registered an ssh key with my github account. The keys are in
~/.ssh/id_rsa_github_snail
~/.ssh/id_rsa_github_snail.pub
I have a repo wherein the remote url is configured to use ssh:
$ git remote -v
origin [email protected]:danielsank/pong.git (fetch)
origin [email protected]:danielsank/pong.git (push)
However, when I try to push from a company computer, I get the following error message
danielsank@snail:~/src/pong$ git push
ssh: connect to host github.com.<company>.<name>.com port 22: Connection timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Notice that ssh is, for some reason, trying to connect to github.com.<company>.<name>.com
instead of github.com
.
I have discovered the following suspicious bit in /etc/resolve.conf
:
# It is common within <company> to lookup hostnames with a dot in it like for an
# example '<machine>.<site>'. We set 'options ndots:2' so that such hostnames
# get tried first with the <company> search domains appended. Without this such
# queries might be tried first against an external DNS resolver.
options ndots:2
I can ping github.com.
I tried setting the url to [email protected].:danielsank/pong.git
.
After doing that, when I try to push, I get asked to accept a host fingerprint from github, but then get a different error:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
which I imagine is happening because of the extra dot in the repo name.
Is there a good way to work around this configuration? I'm kinda surprised that the resolution doesn't try again without appending the company name...
Upvotes: 1
Views: 121
Reputation: 94423
It seems you have strange DNS settings in /etc/resolve.conf
or in a company's nameserver. To prevent these DNS settings to append .<company>.<name>.com
to host names with a dot append a dot at the end of host names:
ping github.com. # <- note the dot!
git remote set-url origin [email protected].:danielsank/pong.git
About the second problem — if you want to use a key with nonstandard name, as you have, you can assign keys to hosts in ~/.ssh/config
:
Host github.com github.com.
User git
IdentityFile ~/.ssh/id_rsa_github_snail
Upvotes: 1