When I generate an ssh key in a different path than the default I can't access by ssh in github, I don't know what the problem is, but I know I have tried many times to generate and use a ssh with a different path than the default and all my attempts have failed.
Can someone explain why? Or say where am I going wrong
It works:
PS C:\Users\sjoao\.ssh> ssh-keygen -t ed25519 -C "sjoaovictor622@gmail.com"
Generating public/private ed25519 key pair.
Enter file in which to save the key (C:\Users\sjoao/.ssh/id_ed25519):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in C:\Users\sjoao/.ssh/id_ed25519
Your public key has been saved in C:\Users\sjoao/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:sBpycUHR17hJwxtmDZFJgZSiNP9XBdlBP41AKQIEc5w sjoaovictor622@gmail.com
The key's randomart image is:
+--[ED25519 256]--+
| o=B*.==@+*o. |
| ooE.= & =.oo.|
| ..+o. * B ...o|
| .o.o + . .|
| . o ..S . |
| o o . . |
| . . |
| |
| |
+----[SHA256]-----+
PS C:\Users\sjoao\.ssh> Start-Service ssh-agent
PS C:\Users\sjoao\.ssh> ssh-add .\id_ed25519
Identity added: .\id_ed25519 (sjoaovictor622@gmail.com)
PS C:\Users\sjoao\.ssh> Get-Content $env:USERPROFILE\.ssh\id_ed25519.pub | Set-Clipboard
PS C:\Users\sjoao\.ssh> git clone git@github.com:jottaVictor/tictactoegame.git
Cloning into 'tictactoegame'...
The authenticity of host 'github.com (20.201.28.151)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
remote: Enumerating objects: 135, done.
remote: Counting objects: 100% (135/135), done.
remote: Compressing objects: 100% (93/93), done.
remote: Total 135 (delta 47), reused 121 (delta 33), pack-reused 0 (from 0)
Receiving objects: 100% (135/135), 45.16 KiB | 388.00 KiB/s, done.
Resolving deltas: 100% (47/47), done.
Dont Work:
PS C:\Users\sjoao\.ssh> ssh-keygen -t ed25519 -C "sjoaovictor622@gmail.com"
Generating public/private ed25519 key pair.
Enter file in which to save the key (C:\Users\sjoao/.ssh/id_ed25519): .\test
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in .\test
Your public key has been saved in .\test.pub
The key fingerprint is:
SHA256:pOwOkkTVPPMaNn01y6VVmp1+B2P0MQgsfpDeq0KV7pM sjoaovictor622@gmail.com
The key's randomart image is:
+--[ED25519 256]--+
| .o o.. o+.|
| . = + .ooo=+|
| . =+ =o **.o|
| . .+oo=.o+..o |
| . .o+S.. . .o|
| . . ... . . o|
| o . o . o |
| . o . E |
| . . . |
+----[SHA256]-----+
PS C:\Users\sjoao\.ssh> Start-Service ssh-agent
PS C:\Users\sjoao\.ssh> ssh-add .\test
Identity added: .\test (sjoaovictor622@gmail.com)
PS C:\Users\sjoao\.ssh> Get-Content $env:USERPROFILE\.ssh\test.pub | Set-Clipboard
PS C:\Users\sjoao\.ssh> git clone git@github.com:jottaVictor/tictactoegame.git
Cloning into 'tictactoegame'...
The authenticity of host 'github.com (20.201.28.151)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
git@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.
The only difference is my answer to 'Enter file in which to save the key (C:\Users\sjoao/.ssh/id_ed25519):' I add both in the list of ssh-keys of github
The issue is likely because SSH is not automatically picking up your custom key. By default, SSH looks for keys in ~/.ssh/id_rsa
or ~/.ssh/id_ed25519
. When using a non-default path, you need to explicitly specify it in your SSH config.
Edit (or create) your SSH config file:
notepad C:\Users\sjoao\.ssh\config
Add the following lines:
Host github.com
IdentityFile C:\Users\sjoao\.ssh\test
IdentitiesOnly yes
Save the file and retry your git clone
command.