-3

Can I somehow get access to root account after changing /etc/passwd file? Similar problems:


Lost root access possibility /sbin/nologin


How do I regain access to root after accidental chsh command that went bad?


But... without physical access to the machine? So... no live cd boot etc?

n0zz
  • 1
  • 1
  • 2
    If it's been setup well, *you don't* get root access remotely by anything outside the normal way. That would be a massive security hole if you could. Therefore you should obtain physical access to it because you're in a disaster recovery situation. – TessellatingHeckler Sep 03 '15 at 20:49
  • Lets say noone has access to the machine, and yet, root access is required... /nologin is not a normal way. It is a possibility, but not the best one to chose. The problem is that, I have no access to su, sudo or anything now. I would rather have only permitrootlogin set as no and secure remote access only to specific networks. Which I had earlier. But I wanted to check what if... And I just fked up. Now I have to get access to my machine to recover from this, just as I though. Anyway, it seems like there is other way. Thanks anyway :) – n0zz Sep 03 '15 at 21:11
  • changing /sbin/nologin is not a possibility because normal users can't edit files in /sbin/. Changing the boot options is not a possibility, because normal users can't change boot options. You haven't actually said what you changed - do you know the root password? Have you tried SFTP connections which might not need shell access? Otherwise, you're looking at either 1) is my server weak, and I can exploit it like a hacker could, to gain root access. 2) I need access to do something outside the OS, e.g. plug a screen and keyboard in and change boot settings during startup, or boot to a live CD. – TessellatingHeckler Sep 03 '15 at 21:24
  • @TessellatingHeckler It is my sever, I had root access, I have root password. I've changed root shell in /etc/passwd. I want to change it back because I need root access to finish up configuring this server. And then I need to configure it withour direct root access, but with usaable sudo or su. Still ned some root permitions to do some things. Thats it. The problem with phisical access is that, that I actually can have it, but I'm in another city and have to wait till I get back home. Is that all so hard to understand? :/ – n0zz Sep 04 '15 at 09:15
  • Having read it three times, yes, it is. – MadHatter Sep 15 '15 at 15:42

1 Answers1

2

If you have another account there with sudo and can login the server, you can do:

sudo su - -s /bin/bash

If it is a cloud server on any cloud provider, let us know as it is a workaround maybe. If it is your server and if you don't have any other mean of login in, I don't think there is a workaround for that (but maybe I'm wrong)

ignivs
  • 449
  • 5
  • 11
  • I have one more user there, but he's not in sudoers group, so I can't use sudo. Its my server, not cloud etc. But I still can't boot a live CD. I can try to connect keyboard there, but with no screen it can be hard to do anything... And still it won't allow me to log in as root. – n0zz Sep 03 '15 at 20:09