We have a server with ssh enabled, and we have: PermitRootLogin: no, and a user that is not in sudoers file. Another administator set invalid Shell for root so I can't get root access anymore. When I run su command and enter root password it says: su: failed to execute /bin/vash. I think the admin wanted to set bash as default Shell but here is a typo.
How can I access root again?
Asked
Active
Viewed 71 times
1
João Paulo
- 127
- 7
Ivan
- 15
- 6
2 Answers
1
From man su:
-s, --shell=shell
Run the specified shell instead of the default.
So try:
su root -s /bin/sh
Then run chsh to reset the shell to a valid default
moo
- 675
- 6
- 14
-
So I wasn't in sudoers file) But I've already fixed that – Ivan Feb 21 '23 at 17:59
-
Thanks anyway ! – Ivan Feb 21 '23 at 17:59
0
Oh guys I've fixed that))) Here is my solution:
cp /bin/bash ~/vash
export PATH = "$PATH:~"
alias "/bin/vash"="/home/USER/vash"
su
Ivan
- 15
- 6
-
I'm struggling to see how this can possibly work - how does an alias defined in the unprivileged shell have any effect on how `su` locates `/bin/vash`? and `export PATH = "$PATH:~"` is invalid (for more than one reason) in at least bash/dash/zsh/ksh. Can you check your command history please? – steeldriver Feb 21 '23 at 18:56
-
@steeldriver Hello, My history matches my post. I understand your doubts because I also wonder how it works but it helped me to access root shell (there I ran chsh command and set bash as a default shell). Maybe I'll try to repeat this on a VM. – Ivan Feb 21 '23 at 21:16