Issue
The Problem
After setting everything up, I am running the repo clone command to clone one of my repositories onto my local machine. However, I keep getting the same error message:
D:\0--Projekte ❯ gh repo clone wiktoriavh/ask-good-questions
Cloning into 'ask-good-questions'...
Enter passphrase for key '/c/Users/Wiktoria/.ssh/id_ed25519':
[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 also get a similar error when trying to ssh into it:
~ ❯ ssh gh-cli
Enter passphrase for key 'C:\Users\Wiktoria\.ssh\id_ed25519':
[email protected]: Permission denied (publickey). 19:16:01
~ ❯ ssh [email protected]
Enter passphrase for key 'C:\Users\Wiktoria/.ssh/id_ed25519':
[email protected]: Permission denied (publickey).
I am on Windows.
What I tried
I have tried a few different things.
gh auth refresh
to refresh my authentication- tried to use a new auth
- created a new ssh key pair
ssh-keygen -t ed25519 -C "[email protected]"
gh auth logout
to logout of my gh cligh auth login
and then I chose SSH, logged in through the browser and chose the new ssh key pair I created earlier. The public key is saved on github.
- created a new ssh key pair
- I updated the
known_hosts
file with the following fingerprints: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/githubs-ssh-key-fingerprints - I updated the
~/.ssh/config
file to include github
Host gh-cli
IdentityFile C:\Users\Wiktoria\.ssh\id_ed25519
HostName github.com
User git
AddKeysToAgent yes
I am not sure what else I could try. I checked out help pages from GitHub and on StackOverflow.
What I expect to happen
I expect to be able to do git actions with GitHub CLI through SSH.
Some Updates
I have tried around, used ssh-add
which seemed to help a littl, howerever I still am unable to clone. I can ssh into github, but not use the gh cli, or git clone
for the matter.
The repository exists: https://github.com/wiktoriavh/ask-good-questions
I also checked if Port 22 is open, however, I did not change any OS host files.
Here is my host file. I tried uncomment the last two lines, but that didn't change anything.
This is the output when I do ssh -vT [email protected]
:
OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
debug1: Reading configuration data C:\\Users\\Wiktoria/.ssh/config
debug1: C:\\Users\\Wiktoria/.ssh/config line 6: Applying options for github.com
debug1: Connecting to github.com [140.82.121.3] port 22.
debug1: Connection established.
debug1: identity file C:\\Users\\Wiktoria\\.ssh\\id_ed25519 type -1
debug1: identity file C:\\Users\\Wiktoria\\.ssh\\id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.1
debug1: Remote protocol version 2.0, remote software version babeld-dd067d10
debug1: no match: babeld-dd067d10
debug1: Authenticating to github.com:22 as 'git'
debug1: C:\\Users\\Wiktoria/.ssh/known_hosts:3: parse error in hostkeys file
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
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: ecdsa-sha2-nistp256 SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM
debug1: C:\\Users\\Wiktoria/.ssh/known_hosts:3: parse error in hostkeys file
debug1: Host 'github.com' is known and matches the ECDSA host key.
debug1: Found key in C:\\Users\\Wiktoria/.ssh/known_hosts:2
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: [email protected] ED25519 SHA256:Z7r525AWfMxUAF8EFoZxznXQa/VU1jLba39P+XwiRIA agent
debug1: Will attempt key: C:\\Users\\Wiktoria\\.ssh\\id_ed25519 explicit
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],[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>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: [email protected] ED25519 SHA256:Z7r525AWfMxUAF8EFoZxznXQa/VU1jLba39P+XwiRIA agent
debug1: Server accepts key: [email protected] ED25519 SHA256:Z7r525AWfMxUAF8EFoZxznXQa/VU1jLba39P+XwiRIA agent
debug1: Authentication succeeded (publickey).
Authenticated to github.com ([140.82.121.3]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Hi wiktoriavh! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 1992, received 2648 bytes, in 0.3 seconds
Bytes per second: sent 6543.8, received 8698.8
debug1: Exit status 1
Solution
I have never been able to use SSH on Windows... in a corporate environment (at work): egress SSH is generally blocked.
But if it is not the case for you, then check with ssh-add -l
that your key is listed. If not, in a Powershell session:
Start-Service ssh-agent
ssh-add C:\Users\Wiktoria\.ssh\id_ed25519
And, for testing, set your configuration to directly point to github.com
instead of using a custom hostname like gh-cli
.
Host github.com
HostName github.com
User git
IdentityFile C:\Users\Wiktoria\.ssh\id_ed25519
AddKeysToAgent yes
Then double-check again your SSH connection, using the verbose output as suggested:
ssh -vT [email protected]
Answered By - VonC Answer Checked By - David Goodson (WPSolving Volunteer)