Reputation: 2270
I want to Push changes via SSH to my git repo.
[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.
I have my ssh-agent up and running. I have my key loaded via ssh-add
. It is the right key, I checked a bunch of times. It is also registered in my github.
When I try to git push origin
I get the error from the above. It is the correct origin.
I also looked into this a lot and someone said that if you have multiple keys to the same git, it gets confused or something, but I have only one key loaded.
I cloned the repo via ssh aswell.
What should I do? I'm stuck on this for over 4 hours and I can't figure it out.
UPDATE
I've ran ssh -v -T [email protected]
and the output is:
OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
debug1: Connecting to github.com [140.82.121.3] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\s/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\s/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\s/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\s/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\s/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\s/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\s/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\s/.ssh/id_ed25519-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\s/.ssh/id_xmss type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\s/.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-b5f98373
debug1: no match: babeld-b5f98373
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:foobar
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in C:\\Users\\foobar/.ssh/known_hosts:1
Warning: Permanently added the RSA host key for IP address 'foobar' to the list of known hosts.
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=<[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
[email protected],[email protected],[email protected],[email protected],ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa,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:Ae2CCQzd33Dczv8gPiRiYEWJ7xwBVOU+719JTJ/5fjQ C:\\Users\\foobar\\.ssh\\foobar\\open_ssh-agent
debug1: Server accepts key: pkalg ssh-rsa blen 279
warning: agent returned different signature type ssh-rsa (expected rsa-sha2-512)
debug1: Authentication succeeded (publickey).
Authenticated to github.com (foobar).
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 vivere! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 2560, received 2468 bytes, in 0.2 seconds
Bytes per second: sent 10852.5, received 10462.5
debug1: Exit status 1
Upvotes: 3
Views: 2096
Reputation: 135
If you are getting these errors from VsCode, follow these steps.
from these images, check the bottom-left account button (git-hub), Logout from there, and log in again. It will work
If it's not working, take the keychain access
delete the accounts which are showing there retry step.1
Thank you.
Upvotes: 0
Reputation: 1323115
If ssh -Tv [email protected] does work, then check if you can contact the remote repo SSH URL with:
git ls-remote [email protected]:<me>/<myRepo>
Then compare that URL with the one registered in your local repository (git remote -v
)
And if it is the same, check the output of git config -l
: look for any directive with insteadOf
in it, in case that URL would be changed by something else.
The OP Vivere reports in the comments:
id_rsa
and save it exactly in ~/.ssh
, following this gist;ssh-add.exe
(the one from OpenSSH)Basically:
C:\Windows\System32\OpenSSH\
Upvotes: 2