Reputation: 81
I'm having a problem similar to the one in git - Server host key not cached, but there is a twist that is making the best solution there not work.
The twist is that I am trying to clone a repository from Stash, an application from Atlassian like git-hub that our company uses for storing its git repositories. After I enter my public key into Stash, I use Git Bash to try to clone a repository from there with the ssh address provided me by the system. This is what results:
$ git clone ssh://[email protected]:7999/teamproject/gitrepo.git
Cloning into 'gitrepo'...
The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:12
Connection abandoned.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Since I'm not using putty to try to connect, I tried the solution of connecting to the server with ssh:
$ ssh ssh://[email protected]:7999/teamproject/gitrepo.git
ssh: stash.mycompany.com:7999/teamproject/gitrepo.git: no address associated with name
If I tried shortening down the address that ssh can recognize, I get a different fingerprint than what git is rejecting:
$ ssh ssh://[email protected]
The authenticity of host 'stash.mycompany.com (10.XX.XXX.XX)' can't be established.
RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:34.
Are you sure you want to continue connecting (yes/no)? no
Host key verification failed.
I choose not to continue connecting because if I do connect, it just puts an entry that does not help git to do its job into my known_hosts file.
Anyone know how to get around this problem?
Upvotes: 1
Views: 2151
Reputation: 81
I had a colleague give me a hint that eventually got me past my problem. The answer to the immediate question I posted above was that I was not giving ssh the port number in the format it expected. You don't specify the port number like this...
ssh stash.mycompany.com:7999
...but rather like this:
ssh -p 7999 stash.mycompany.com
This syntax caused ssh to ask if I wanted to store the host in the list of known hosts, and it gave me the fingerprint that Stash had told me it was supposed to use. (After I said yes, ssh hung up my Git Bash prompt and I had to kill the entire Git Bash session and start a new one. But at least the host had already been stored in the known_hosts file. :) )
Once I was past that problem, the only other thing I had to do was apply a solution in this thread github: No supported authentication methods available, which was to set the GIT_SSH variable in my .bash_profile for the Git Bash
export GIT_SSH=/bin/ssh.exe
After I had done that and restarted Git Bash, git started working using my ssh key.
Upvotes: 4