/etc/passwd
ルートログイン時にこのコマンドを使用したときに設定ミスをしました
root@ubuntu:~# sh -c 'echo "nope no entry mates" > /etc/passwd'
今、どのユーザーやルートアカウントからでもVPSにアクセスしようとすると、
ssh root@myVpsIp
kex_exchange_identification: read: Connection reset
SSH デバッグ
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
問題の解決策を見つけようとしたルートSSHウィンドウがまだログインしたままで、問題に遭遇しました
root@ubuntu:~# cut -d : -f 1 /etc/passwd
nope no entry mates
復元する方法を知っている人はいますか/etc/passwd
?
答え1
/var/backups/passwd.bakにある/etc/passwdのバックアップがあるかどうかを確認し、実行してcp /var/backups/passwd.bak /etc/passwd
から実行するchmod 644 /etc/passwd
/var/backups/passwd.bakがない場合は、/etc/passwd-を使用できます。
最初に実行したコマンドで /etc/passwd ファイル全体が削除されたようです。