winlin
Goto Top

Putty SSH Problem server refused key

Hallo Leute,

ich habe folgendes Problem. Ich habe einen Win10 Rechner und habe einen entfernten Linux Rechner. Von dem Linux Rechner habe ich eine PEM File und ein PUB File. Aus dem PEM File habe ich mir eine PPK File erstellt um per Putty auf den Linux Rechner zu kommen. Wenn ich aber einen Verbindungsversuch starte dann erhalte ich den Fehler
server refused our key
no supported authentication methods available: server sent: publickey

Wenn ich in meinen Ordner /.ssh schaue dann habe ich dort:
meinkey
meinkey.pub
known_hosts

Im File known_hosts ist auch der Servereintrag vom Linuxrechner enthalten.
<code
10.XXX.XXX.XX ecdsa-sha2-nistp256 ..........


Wenn ich z.b. in der Powershell die Debug option zum ssh hinzufüge erhalte ich folgenden outpu:
PS C:\Users\xxx\.ssh> ssh -vvv ubuntu@10.xxx.xxx.xx
OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
debug3: Failed to open file:C:/Users/xxx/.ssh/config error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_config error:2
debug2: resolve_canonicalize: hostname 10.xxx.xxx.xx is address
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 10.xxx.xxx.xx [10.xxx.xxx.xx] port 22.
debug1: Connection established.
debug3: Failed to open file:C:/Users/xxx/.ssh/id_xmss.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\xxx/.ssh/id_xmss type -1
debug3: Failed to open file:C:/Users/xxx/.ssh/id_xmss-cert error:2
debug3: Failed to open file:C:/Users/xxx/.ssh/id_xmss-cert.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\xxx/.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 OpenSSH_7.2p2 Ubuntu-4ubuntu2.10
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.10 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to 10.xxx.xxx.xx:22 as 'ubuntu'  
debug3: hostkeys_foreach: reading file "C:\\Users\\xxx/.ssh/known_hosts"  
debug3: record_hostkey: found key type ECDSA in file C:\\Users\\xxx/.ssh/known_hosts:3
debug3: load_hostkeys: loaded 1 keys from 10.xxx.xxx.xx
debug3: Failed to open file:C:/Users/xxx/.ssh/known_hosts2 error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts2 error:2
debug3: order_hostkeyalgs: prefer hostkeyalgs: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none
debug2: compression stoc: none
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1
debug2: host key algorithms: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519
debug2: ciphers ctos: aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
debug2: ciphers stoc: aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
debug2: MACs ctos: hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com
debug2: MACs stoc: hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com
debug2: compression ctos: none,zlib@openssh.com
debug2: compression stoc: none,zlib@openssh.com
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: aes128-ctr MAC: umac-128-etm@openssh.com compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: umac-128-etm@openssh.com compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:AAABBBPxWmPaF6rpZkyhHmxq8dQJ2h8tlHFX07bbJIE
debug3: hostkeys_foreach: reading file "C:\\Users\\xxx/.ssh/known_hosts"  
debug3: record_hostkey: found key type ECDSA in file C:\\Users\\cen1wa3/.ssh/known_hosts:3
debug3: load_hostkeys: loaded 1 keys from 10.140.145.28
debug3: Failed to open file:C:/Users/cen1wa3/.ssh/known_hosts2 error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts2 error:2
debug1: Host '10.XXX.XXX.XX' is known and matches the ECDSA host key.  
debug1: Found key in C:\\Users\\xxx/.ssh/known_hosts:3
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey after 4294967296 blocks
debug3: unable to connect to pipe \\\\.\\pipe\\openssh-ssh-agent, error: 2
debug1: pubkey_prepare: ssh_get_authentication_socket: No such file or directory
debug2: key: C:\\Users\\xxx/.ssh/id_rsa (0000000000000000)
debug2: key: C:\\Users\\xxx/.ssh/id_dsa (0000000000000000)
debug2: key: C:\\Users\\xxx/.ssh/id_ecdsa (0000000000000000)
debug2: key: C:\\Users\\xxx/.ssh/id_ed25519 (0000000000000000)
debug2: key: C:\\Users\\xxx/.ssh/id_xmss (0000000000000000)
debug3: send packet: type 5
Corrupted MAC on input.
ssh_dispatch_run_fatal: Connection to 10.XXX.XXX.XX port 22: message authentication code incorrect

Content-Key: 664393

Url: https://administrator.de/contentid/664393

Printed on: April 26, 2024 at 07:04 o'clock

Member: NordicMike
Solution NordicMike Mar 18, 2021 at 08:08:25 (UTC)
Goto Top
Setze mal bei allen Zeilen an, die mit "Failed to open file" beginnen. Prüfe ob die Dateien vorhanden sind bzw warum sie anders heissen als die Dateien, wie du sie benannt hast.
Member: winlin
winlin Mar 18, 2021 at 08:28:16 (UTC)
Goto Top
der letzte output ist nur ein beispiel...ich mache eigentlich kein ssh über powershell sondern nur ueber putty.
Andere Linux Instanzen funktionieren per putty. DAzu nehme ich immer das PEM FIle generiere eine PPK und verbinde mich dann per putty, Geht bei allen nur bei der einen VM nicht?!?!?!? Wieso kommt dieo.g. Fehlermeldung ....server sent: publickey
Member: HanTrio
Solution HanTrio Mar 18, 2021 at 09:22:12 (UTC)
Goto Top
"Wieso kommt dieo.g. Fehlermeldung ....server sent: publickey"
-> bedeutet: "Hallo, ich biete diese Methoden der Authentifizierung an" (hier: eben ausschließlich per key).

Du könntest ausprobieren, ob du per Passwort auf den Server rauf kommst.
Hierzu auf dem Zielserver in der /etc/ssh/sshd_config nach der Zeile
PasswordAuthentication
suchen und diese temporär auf "yes" stellen (anschließend den ssh daemon neu starten bzw. die config reloaden).

Dann kannst du zumindest schnell feststellen, ob ssh an sich funktioniert.
Was es aber recht offensichtlich tut:
debug1: Connecting to 10.xxx.xxx.xx [10.xxx.xxx.xx] port 22.
debug1: Connection established.

Ansonsten würde ich jedoch auch auf einen "irgendwie" falsch erstellten key tippen, entweder bei der Erstellung an sich, oder eben in einer Datei hinterlegt, die so nicht gefunden wird.

Schau mal auf dem Zielrechner, was da an authorisierten keys hinterlegt ist in der
$HOME/.ssh/authorized_keys
-> wenn du dich als root einlogst, dann eben unter /root/.ssh/authorized_keys

Evtl ist der key (speziell in Verbindung mit Putty) falsch formatiert, siehe hier:
https://askubuntu.com/questions/204400/ssh-public-key-no-supported-authe ...
Member: winlin
winlin Mar 18, 2021 at 09:23:59 (UTC)
Goto Top
Danke für den Tipp, habe alles nochmal neu gemacht und jetzt geht esface-smile
Member: Lochkartenstanzer
Lochkartenstanzer Mar 18, 2021 updated at 10:03:45 (UTC)
Goto Top
Zitat von @HanTrio:

-> wenn du dich als root einlogst, ...

Das macht man nicht per ssh! Niemals nicht!eins!elf! face-smile

lks
Member: winlin
winlin Mar 20, 2021 at 08:27:09 (UTC)
Goto Top
Du hast recht es war schlicht und einfach der Key falschface-smile