Search code examples
ubuntusshubuntu-server

locked root with no other user account login ubuntu ssh


i think i have made a big mistake on a vps ubuntu tls through ssh i locked root acount without first to make a user's account login.

I have active winscp connection with the server and i can edit or upload new /etc/passwd and shadow files (passwd- shadow- also exists)

some lines from passwd ( i have created user vmail but hadn't add password/login?)

root:x:0:0:root:/root:/bin/bash
vmail:x:5000:5000::/var/spool/vmail:

/etc/passwd-

root:x:0:0:root:/root:/bin/bash
virtual:x:1000:1000:,,,:/home/virtual:/bin/bash
vmail:x:5000:5000::/var/spool/vmail:

/etc/shadow

root:!:16514:0:99999:7:::
vmail:!:16513:0:99999:7:::

/etc/shadow- (changed abit middle letters in pass)

root:$6$PRLOUfho$IzxfU9eeHgrytOkckbsdb7neDIz.3v9swIWOk0osPfAMVXil0VPArTdzwbD766G7232DPKylZomL/o/50ZtIh0:16514:0:99999:7:::
vmail:*:16513:0:99999:7:::

Solution

  • Two options:

    • SCP is just one of several protocols that work over the same connection. You should be able to open up a terminal session from winscp and just run passwd
    • you could try and make a backup of your /etc/shadow, and replace the root line with the line from a system where you know the root password.