Score:0

Can't access my VPS through SSH

de flag

I just misconfigured my /etc/passwd had used this command on root login

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

Now whenever I try to access my VPS though any user, or root account, I get

ssh root@myVpsIp
kex_exchange_identification: read: Connection reset

SSH Debug

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

There is still a logged in root ssh window in which I tried to find the problem solution and got to the issue

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

Anybody know how to restore my /etc/passwd?

tommy_shelby avatar
de flag
had user pwck -qr and it shows my user accounts are there had followd this guide [link](https://www.digitalocean.com/community/tutorials/how-to-restrict-log-in-capabilities-of-users-on-ubuntu)
Score:2
cn flag

See if you have backup of /etc/passwd located in /var/backups/passwd.bak and if you have run cp /var/backups/passwd.bak /etc/passwd and then run chmod 644 /etc/passwd

If you don't have /var/backups/passwd.bak, you can use /etc/passwd-

It seems you have deleted your entire /etc/passwd file with the first command that you've run.

tommy_shelby avatar
de flag
voila you're right. had just moved from widows 10 to linux trying to learn operating linux using vps
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.