Issue
So I am trying to clone my repository via ssh
.
For that purpose, I have:
- created private and public keys using
ssh-keygen
. - Added the private key using
ssh-add
. - Added the public key to a GitHub account.
And finally, when I try to git clone
.. my remote repo I got an error:
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
P.S nothing from GitHub FAQ about the "Permission denied" topic helped me.
EDIT:
ssh -vT [email protected]
OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
debug1: Connecting to github.com [140.82.118.3] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\.../.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\.../.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\.../.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\.../.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\.../.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\.../.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\.../.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\.../.ssh/id_ed25519-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\.../.ssh/id_xmss type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\.../.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_7.7
debug1: Remote protocol version 2.0, remote software version babeld-5a455904
debug1: no match: babeld-5a455904
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: rsa-sha2-512
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in C:\\Users\\.../.ssh/known_hosts:4
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-rsa,rsa-sha2-512,rsa-sha2-256,ssh-dss>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:LsIWcaAcRR0Lh880/ImF1Ex9doM47aqEqt9rXcl3BTE c:/users/.../.ssh/github/key
debug1: Server accepts key: pkalg ssh-rsa blen 535
warning: agent returned different signature type ssh-rsa (expected rsa-sha2-512)
debug1: Authentication succeeded (publickey).
Authenticated to github.com ([140.82.118.3]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Hi Nickpofig! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 3328, received 2484 bytes, in 0.2 seconds
1
s
Solution
Ok, the problem was specific to my system, so you wouldn't be able to help, however, thanks anyway. After research what is GIT_SSH_COMMAND about, I found out that git uses it in order to set user application as an establisher of ssh communication. In my case, I didn't have that variable listed in my environment, so I added "GIT_SSH" (also works fine for git) manually via the command line: setx GIT_SSH C:/WINDOWS/System32/OpenSSH/ssh.exe
. Just in case, check the path of your ssh.exe via command: Get-Command ssh
(Get-Command just gives you a path of the given environment variable) and put it after GIT_SSH (your new environment variable, which would be used by git to establish ssh communication). And that's it.
Be aware, don't use just set
command - it would add a variable only for a current terminal session, so it is useless in our case.
Of courses, your problem of cloning a git repository may have a different root. However, if you check your "GIT_SSH" variable being set that would eliminate my problem case in your situation.
Answered By - user11141172