Forum: PC-Programmierung Github Publickey denied


Announcement: there is an English version of this forum on EmbDev.net. Posts you create there will be displayed on Mikrocontroller.net and EmbDev.net.
von Chandler B. (chandler)


Lesenswert?

Hallo,
ich habe ein Problem mit Github.
Ich habe einen PC mit Windows und Git.
mittels der Git-Bash habe ich mir einen RSA-Key generiert und diesen in 
Github hochgeladen.
1
ssh-rsa AAAAB3NzaC1y..........
wenn ich jetzt das Projekt clonen möchte, bekomme ich den Fehler
1
git@github.com: Permission denied (publickey).
2
fatal: Could not read from remote repository.
3
4
Please make sure you have the correct access rights
5
and the repository exists.
in der Datei ~/.ssh/known_hosts steht auch nur ein key
1
github.com ssh-ed25519 AAAAC3NzaC1.......
auch wenn ich diese datei lösche und neu erstelle, steht nur derselbe 
key drinn.
In Github selber, steht aber nur mein RSA-Key.

was kann/habe ich falsch gemacht?

von Εrnst B. (ernst)


Lesenswert?

Versuch ein
> ssh -v git@github.com

Und schau dir in der Log-Ausgabe an, ob der auch den Secret-Key zu dem 
Public-Key, den du bei github hinterlegt hast, einliest.

von Chandler B. (chandler)


Lesenswert?

Εrnst B. schrieb:
> Versuch ein
>> ssh -v git@github.com
>
> Und schau dir in der Log-Ausgabe an, ob der auch den Secret-Key zu dem
> Public-Key, den du bei github hinterlegt hast, einliest.
1
OpenSSH_9.9p2, OpenSSL 3.2.4 11 Feb 2025
2
debug1: Reading configuration data /etc/ssh/ssh_config
3
debug1: Connecting to github.com [140.82.121.4] port 22.
4
debug1: Connection established.
5
debug1: identity file /c/Users/Chandler/.ssh/id_rsa type -1
6
debug1: identity file /c/Users/Chandler/.ssh/id_rsa-cert type -1
7
debug1: identity file /c/Users/Chandler/.ssh/id_ecdsa type -1
8
debug1: identity file /c/Users/Chandler/.ssh/id_ecdsa-cert type -1
9
debug1: identity file /c/Users/Chandler/.ssh/id_ecdsa_sk type -1
10
debug1: identity file /c/Users/Chandler/.ssh/id_ecdsa_sk-cert type -1
11
debug1: identity file /c/Users/Chandler/.ssh/id_ed25519 type -1
12
debug1: identity file /c/Users/Chandler/.ssh/id_ed25519-cert type -1
13
debug1: identity file /c/Users/Chandler/.ssh/id_ed25519_sk type -1
14
debug1: identity file /c/Users/Chandler/.ssh/id_ed25519_sk-cert type -1
15
debug1: identity file /c/Users/Chandler/.ssh/id_xmss type -1
16
debug1: identity file /c/Users/Chandler/.ssh/id_xmss-cert type -1
17
debug1: Local version string SSH-2.0-OpenSSH_9.9
18
debug1: Remote protocol version 2.0, remote software version 133e47a51
19
debug1: compat_banner: no match: 133e47a51
20
debug1: Authenticating to github.com:22 as 'git'
21
debug1: load_hostkeys: fopen /c/Users/Chandler/.ssh/known_hosts2: No such file or directory
22
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
23
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
24
debug1: SSH2_MSG_KEXINIT sent
25
debug1: SSH2_MSG_KEXINIT received
26
debug1: kex: algorithm: curve25519-sha256
27
debug1: kex: host key algorithm: ssh-ed25519
28
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
29
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
31
debug1: SSH2_MSG_KEX_ECDH_REPLY received
32
debug1: Server host key: ssh-ed25519 SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU
33
debug1: load_hostkeys: fopen /c/Users/Chandler/.ssh/known_hosts2: No such file or directory
34
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
35
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
36
debug1: Host 'github.com' is known and matches the ED25519 host key.
37
debug1: Found key in /c/Users/Chandler/.ssh/known_hosts:1
38
debug1: ssh_packet_send2_wrapped: resetting send seqnr 3
39
debug1: rekey out after 134217728 blocks
40
debug1: SSH2_MSG_NEWKEYS sent
41
debug1: expecting SSH2_MSG_NEWKEYS
42
debug1: ssh_packet_read_poll2: resetting read seqnr 3
43
debug1: SSH2_MSG_NEWKEYS received
44
debug1: rekey in after 134217728 blocks
45
debug1: SSH2_MSG_EXT_INFO received
46
debug1: kex_ext_info_client_parse: server-sig-algs=<ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa>
47
debug1: SSH2_MSG_SERVICE_ACCEPT received
48
debug1: Authentications that can continue: publickey
49
debug1: Next authentication method: publickey
50
debug1: Will attempt key: /c/Users/Chandler/.ssh/id_rsa
51
debug1: Will attempt key: /c/Users/Chandler/.ssh/id_ecdsa
52
debug1: Will attempt key: /c/Users/Chandler/.ssh/id_ecdsa_sk
53
debug1: Will attempt key: /c/Users/Chandler/.ssh/id_ed25519
54
debug1: Will attempt key: /c/Users/Chandler/.ssh/id_ed25519_sk
55
debug1: Will attempt key: /c/Users/Chandler/.ssh/id_xmss
56
debug1: Trying private key: /c/Users/Chandler/.ssh/id_rsa
57
debug1: Trying private key: /c/Users/Chandler/.ssh/id_ecdsa
58
debug1: Trying private key: /c/Users/Chandler/.ssh/id_ecdsa_sk
59
debug1: Trying private key: /c/Users/Chandler/.ssh/id_ed25519
60
debug1: Trying private key: /c/Users/Chandler/.ssh/id_ed25519_sk
61
debug1: Trying private key: /c/Users/Chandler/.ssh/id_xmss
62
debug1: No more authentication methods to try.
63
git@github.com: Permission denied (publickey).

was ich hier sehen kann, ist dass id_rsa eingelesen wird? Die keys 
heißen aber github und github.pub

kann das das problem sein?

von Chandler B. (chandler)


Lesenswert?

Chandler B. schrieb:
> kann das das problem sein?

Ja, das war das problem.
jetzt heißen die Dateien id_rsa und id_rsa.pub.
Damit funktioniert jetzt alles :/

von Bernd H. (geeky)


Lesenswert?

Den Dateinamen des für den jeweiligen Host zu verwendenen Keyfiles kann 
man auch selbst aktiv setzen via "~/.ssh/config"-Datei: 
https://stackoverflow.com/a/56536275

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.