I'm attempting to clone a repo from my BitBucket account to my Windows 10 laptop (running GitBash). I've completed all of the steps necessary to connect (set up my SSH key, verified by successfully SSHing git@bitbucket.org, etc). However, whenever I attempt to clone a repo, the prompt continually hangs up after confirming that I want to cache Bitbucket's key.
User@Laptop MINGW64 /C/Repos
$ git clone git@bitbucket.org:mygbid/test.git
Cloning into 'test'...
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 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40
If you trust this host, enter "y" to add the key to
PuTTY's cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n) y
No files are cloned, and the result is an empty repo. Trying to initiate a git pull origin master from this repo also asks to cache the key, then hangs with no feedback. Despite not asking for the key to be cached when I do a test SSH, git operations always ask for the key every time before failing.
With no error messages to work with, I'm really at a loss as to what is wrong. I've tried multiple repos, including very small ones, with no success at all.
I managed to get it working by running plink directly, after pageant is running use the plink command directly -
plink.exe -agent -v git@github.com
then after this git works without hanging.Even after performing the workaround mentioned in other answers, you may encounter an error like:
To solve both problems at once, change git bash to use SSH instead of PuTTY by adding the following to your
~/.profile
file (C:\Users\<Username>\.profile
). If you don't already have this file, then create a new file with this line.Then open a new git bash window and try your
git clone
orgit pull
again.Note that this may require you to create an SSH key if you don't already have one. To do this, follow the instructions on the Bitbucket site.
See this SO question for related info.
To do this from powershell open a powershell window and paste in the following:
or with PuTTY standalone version:
Also worth knowing is that putty stores known hosts under a registry key:
To shortcut the above you could put the following in a
.reg
file and run it:putty-hosts.reg gist
It sounds a bit silly, but after trying all of the above, I decided to reinstall Git Bash with default options and it worked.
bitbucket.org
)To workaround this problem I configured GitBash to use plink with
-batch
option. The option disables all prompts - the plink will terminate without hanging and won't add any key fingerprint to cache.To add
-batch
parameter to plink command executed by GitBash you can set a git config option:Or set
GIT_SSH_COMMAND
environment variable.The output when you cloning a repo from unknown host will be similar to this:
After this message you can add a key to cache with command:
REMARK: Please check if plink is in your
PATH
. Alternatively use UNIX-like path in the GitBash config option, e.g.: