Ich kann nicht über SSH auf meinen VPS zugreifen

Ich kann nicht über SSH auf meinen VPS zugreifen

Ich habe es einfach falsch konfiguriert und /etc/passwddiesen Befehl beim Root-Login verwendet.

root@ubuntu:~# sh -c 'echo "nope no entry mates" > /etc/passwd'

Wenn ich jetzt versuche, über einen beliebigen Benutzer oder Root-Account auf meinen VPS zuzugreifen, erhalte ich

ssh root@myVpsIp
kex_exchange_identification: read: Connection reset

SSH-Debugging

C:\Users\tommy>ssh root@myVpsIp -v    
OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
debug1: Connecting to myVpsIp [myVpsIp] port 22.
debug1: Connection established.
debug1: identity file C:\\Users\\tommy/.ssh/id_rsa type -1
debug1: identity file C:\\Users\\tommy/.ssh/id_rsa-cert type -1
debug1: identity file C:\\Users\\tommy/.ssh/id_dsa type -1
debug1: identity file C:\\Users\\tommy/.ssh/id_dsa-cert type -1
debug1: identity file C:\\Users\\tommy/.ssh/id_ecdsa type -1
debug1: identity file C:\\Users\\tommy/.ssh/id_ecdsa-cert type -1
debug1: identity file C:\\Users\\tommy/.ssh/id_ed25519 type -1
debug1: identity file C:\\Users\\tommy/.ssh/id_ed25519-cert type -1
debug1: identity file C:\\Users\\tommy/.ssh/id_xmss type -1
debug1: identity file C:\\Users\\tommy/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.1
kex_exchange_identification: Connection closed by remote host

Es gibt immer noch ein angemeldetes Root-SSH-Fenster, in dem ich versucht habe, die Problemlösung zu finden und zum Problem gekommen bin

root@ubuntu:~# cut -d : -f 1 /etc/passwd
nope no entry mates

Weiß jemand, wie ich mein wiederherstellen kann /etc/passwd?

Antwort1

Überprüfen Sie, ob Sie eine Sicherungskopie von /etc/passwd in /var/backups/passwd.bak haben und ob Sie diese ausgeführt haben. cp /var/backups/passwd.bak /etc/passwdFühren Sie anschließend Folgendes aus:chmod 644 /etc/passwd

Wenn Sie /var/backups/passwd.bak nicht haben, können Sie /etc/passwd- verwenden.

Es scheint, dass Sie mit dem ersten ausgeführten Befehl Ihre gesamte Datei /etc/passwd gelöscht haben.

verwandte Informationen