0

I have a Windows 7 machine to which I have SSH access. I want to clone a git repo in a particular directory in that machine using SSH protocol. I am trying to clone the repo by logging into the remote Windows 7 machine using SSH(PuTTY) but I get the following error at the console:

git@xyz-github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

But I am able to clone the same repo if I do it via Remote Desktop(mstsc) or VNC viewer. Can someone help me with what is missing here in the PuTTY approach? Eventually, I want to automate the cloning process using Python & fabric.

Here's the output of ssh git@xyz-github.com -v :

OpenSSH_7.6p1, OpenSSL 1.0.2m  2 Nov 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to xyz-github.com [xxx.yyy.zzz.www] port 22.
debug1: Connection established.
debug1: identity file /c/Users/admin/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/admin/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/admin/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/admin/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/admin/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/admin/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/admin/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/admin/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6
debug1: Remote protocol version 2.0, remote software version libssh-0.7.0
debug1: no match: libssh-0.7.0
debug1: Authenticating to xyz-github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:YppvE1IGqHnKCcW9FqBzT4wBdyHxS0XBChnQNu4zCn0
debug1: Host 'xyz-github.com' is known and matches the ECDSA host key.
debug1: Found key in /c/Users/admin/.ssh/known_hosts:1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:yJ5QUUudzMLgW4w8x1o5idxyGbqmeoLilEPiKQnM5gs /c/Users/admin/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to xyz-github.com ([xxx.yyy.zzz.www]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: network
PTY allocation request failed on channel 0
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Hi rakesh! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Connection to xyz-github.com closed.
Transferred: sent 2880, received 1384 bytes, in 0.5 seconds
Bytes per second: sent 5594.4, received 2688.4
debug1: Exit status 1
Rakesh K
  • 8,237
  • 18
  • 51
  • 64
  • Is there a valid private key? – Oliver Charlesworth Dec 05 '17 at 15:28
  • Can you run the following to help us debug? GIT_SSH_COMMAND="ssh -v" git clone – Edmund Dipple Dec 05 '17 at 15:30
  • yes, there's a valid private key in the .ssh folder - the 'id_rsa' file. and cloning actually works when I do an RDP connection. – Rakesh K Dec 05 '17 at 15:30
  • @EdmundDipple tried running 'GIT_SSH_COMMAND="ssh -v" git clone ' on the remote machine but it complained that GIT_SSH_COMMAND is not recognized, am I missing something? – Rakesh K Dec 05 '17 at 15:35
  • 1
    OK in that case, could you run "ssh git@github.com -v"? – Edmund Dipple Dec 05 '17 at 15:52
  • Perhaps you can explain a little more. It sounds like things work when you RDP into the box, but don't when you SSH into the box? Something about this scenario doesn't make much sense. Where is your private key--local (where you run RDP from) or remote (the machine your connected to via RDP)? – John Szakmeister Dec 05 '17 at 16:10
  • @jszakmeister the private key is on the machine to which I am connecting via RDP – Rakesh K Dec 05 '17 at 16:22

1 Answers1

0

Perhaps a credential helper does the job?

In the end git config --list --show-origin should look like this:

file:"C:\\Git\\mingw64/etc/gitconfig"   credential.helper=manager
file:C:/Users/user/.gitconfig    credential.helper=wincred
file:.git/config        remote.origin.url=https://github.com/xy

For details see this question.

Christoph
  • 6,841
  • 4
  • 37
  • 89
  • here's what i see: file:"C:\\Program Files\\Git\\mingw64/etc/gitconfig" credential.helper=manager but no credential helpers in /user/.gitconfig – Rakesh K Dec 05 '17 at 16:19
  • What do you mean? My suggestion was about git config, not ssh output. – Christoph Dec 05 '17 at 16:22
  • ok, so should i have the `credential.helper=wincred' in the .gitconfig file? – Rakesh K Dec 05 '17 at 16:24
  • Yes, this may be an option. Actually, that is the way, I access repos it is simple and rliable. See [here](https://git-scm.com/docs/gitcredentials). – Christoph Dec 05 '17 at 16:32