![SSH를 통해 내 VPS에 액세스할 수 없습니다](https://rvso.com/image/1070933/SSH%EB%A5%BC%20%ED%86%B5%ED%95%B4%20%EB%82%B4%20VPS%EC%97%90%20%EC%95%A1%EC%84%B8%EC%8A%A4%ED%95%A0%20%EC%88%98%20%EC%97%86%EC%8A%B5%EB%8B%88%EB%8B%A4.png)
/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 파일을 삭제한 것 같습니다.