Win console hangs after trying to clone a git repo [duplicate] - windows

This question already has answers here:
Git clone / pull continually freezing at "Store key in cache?"
(10 answers)
Closed 5 years ago.
I have a remote repo which I want to clone. I've set up pageant.exe and added private key. Also added GIT_SSH variable which points to plink.exe. And after clone command I get such output
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.
...
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)
When typing y or n nothing happens, console just hangs and I have to terminate the command with Ctrl+C
Why this happens and how to fix this?

After several hours of investigation I finally found a solution.
The putty has to know smth about the host you're connecting to, namely host must be known_host to putty. Putty stores information about know_hosts under
HKEY_CURRENT_USER\SoftWare\SimonTatham\PuTTY\SshHostKeys registry key. To force putty to add information about that host to registry key we can by accessing via putty.exe using your private key. On first access putty will ask you to add that host to known_hosts. After that git clone command finishes successfully.
Maybe this will be helpful for somebody, because it's not obvious from the first glance

Related

Connecting to remote server with SSH keys

I have been trying to figure out where I am going wrong for a few days now.
I am trying to set up a pair of SSH keys, so my computer can remotely connect to my web server and run a script without a password.
I have generated the SSH keys on my Mac and placed the public key on the server in the '.ssh' folder, then added this to the 'authorized_keys' file.
When I run my command through terminal, I get the following, asking for both a passphrase and the password still.
Christophers-MacBook-Pro:~ christopherdavies$ bash /Users/christopherdavies/Desktop/rsync/chrisdavies/chrisdavies.sh
Enter passphrase for key '/Users/christopherdavies/.ssh/id_rsa':
chrisdavies#shell.host.co.uk's password:
Am I right to have placed the public key from my SSH keys pair on my Mac onto the server?
I am a bit lost here, so would really appreciate some advice. I am slowly learning, but feel I may be doing something blatantly obviously wrong...
It seems you are off to a good start. Some things to check:
make sure you stored the public key under .ssh/authorized_keys on the same user to which you intend to connect. In your case, it seems that your remote user is "chrisdavies", so it should be under ~chrisdavies/.ssh/autorized_keys.
make sure your script connects to the remote server as "chrisdavies". You might want to check that because you are under a different user on your MacBook "christopherdavies".
To troubleshoot, try to SSH to the remote server instead of running the script directly. If you run "ssh chrisdavies# and it works without the password, you do not have connectivity issues, and you'll need to look into your script.
I hope that helps!

pscp works for one account but does not work for another

I have two accounts A, B both registered on the windows server 2008 R2.
There is a script in which I use pscp module of putty to transfer files from the server.
Problem being that the command runs successfully using user account A but gets stuck using account B. The command does not complete using user account B
I have to manually terminate it.
Both accounts have the below privilege in group policy and computer management.
Administrator
Logon as a batch
Replace process level token
Please help
I figured out the problem. When we use pscp alone on command prompt , this is the prompt we get
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 1024
cc:78:13:a3:68:a6:59:7e:b8:23:2d:13:3e:66:9b:b9 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)
Connection abandoned.
We need to press y/n and the command shall thereafter proceed.
While this command was running in the script , the prompt was not getting any input from the user and was therefore never ending.
To mitigate this
one can do something like this
How to pass value to psftp prompt

How to auto approve console request on Jenkins

I'm doing a integration with jenkins and github, and after it compiles the project i want to push the .exe file to github.
I already did the configurarions of SSH on my console (i'm using windows with putty to manage the ssh keys)
but when the jenkins will run the post build console command it returns me this :
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.
and still in this message for ever i want to know how o do approve this message when jenkins request this.
When logged in as the user that Jenkins runs as, use putty to manually connect to the destination and accept the request to put the key in putty's cache. If Jenkins is running as a service, go to Services and check the "Log On" tab in the Properties dialog to see who it's running as.
If you want to add the key to putty's cache manually, the key is mentioned in this superuser question.

Passworded ssh key suddenly does *not* require that I type the password

I use console2 in combination with git bash in order to interact with my local git repositories and by extension several github and bitbucket repositories also.
I use an ssh key pair to authenticate myself to these services, howevermy ssh key pair has an associated password.
This morning I found that I was no longer required to enter this password n my laptop in order to complete the authentication process.
I did some testing and it seems that the same key present on my desktop machine still requires me to enter my password.
So my question is.... why am I no longer required to enter my password on my laptop in order to authenticate with these servers?
Sounds like you have ssh-agent (sshagent.exe) running.
It is a small utility which allows you to enter your key's passphrase once and it then holds it "unlocked" for further use without you needing to re-enter the passphrase each time. Killing it will cause the original behaviour.
ssh-agent comes along with ssh in a standard msysgit installation. I'm not sure if something's changed that now means it's used by default or not though. Another explanation as to why it's running might be if you've installed posh-git and ran a Powershell session. By default (I believe - it's been a while), it'll run at the start of the session and ask for your key's passphrase. I use it every single day with this configuration as my passphrase is quite long... :-)
Something to do with having git-credential-winstore installed on your laptop?

ssh with putty from session 0 gives 'servers host key does not match ...' alert

I have some test code running from TeamCity. Part of my test code requires ssh with putty. This code works fine in in a command prompt (session 1) but when I run it from TeamCity (which is a process and therefore runs in session 0) I get the following alert in my test log
The servers host key does not match the one PuTTY has cached in the registry
[snip]
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)
Since this is in session 0 I can't interact and hit 'y'. I can't work out why the key stored in the registry when I hit 'y' when running this the first time from session 1 doesn't stop the alert appearing in session 0.
Can anyone help me? Thanks.
Very likely there is no solution with PuTTY.
In OpenSSH you have a set of options to completely avoid the host key verification, with the drawback of lowering the security levels.
On Unix derivatives that would be:
-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
I think in Windows the second option would read "-o UserKnownHostsFile=NULL".
One possible "workaround" would be to manually start putty on the very first connection in order to get the host key in the stored cache. Subsequent calls would not require the interaction unless the host key changes (usually due to either a system re-installation or just the SSH server reinstallation).

Resources