Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Tue Apr 05, 2011 5:35 am 
Offline
Newbie

Joined: Tue Apr 05, 2011 5:19 am
Posts: 3
Hi all,

I have a big dilemma on my hands, and am on my last straw trying to solve this. While typing too fast and wanting to change the shell for a given user to prevent SSH access, I ran the following command:

Code:
sudo chsh /sbin/nologin


Without specifying the user, it seemed as though it defaulted to making the root shell /sbin/nologin, not good!

I booted into recovery mode, and followed these steps:

    mounted /dev/xvda /media/xvda
    edited /etc/passwd to change root shell back to /bin/bash
    Checked file again, shell set to bin bash
    Added user "onestp" to sudoers list as a fallback
    ran sudo usermod -s /bin/bash root and was no change, so shell was correct
    changed root password to be sure
    Exited & rebooted

Now when I SSH in as root I still have no acccess. When I SSH in as user onestp (with sudo ability) and run this command:

Code:
sudo su -s /bin/bash root


But when typing in password I still get the error that /sbin/nolong does not exists, so the shell is not changing for user root.

Any ideas on how I can recover access to my VPS as root user?

Thank you,
Simon


Last edited by onestuckpixel on Tue Apr 05, 2011 6:21 am, edited 1 time in total.

Top
   
 Post subject:
PostPosted: Tue Apr 05, 2011 5:56 am 
Offline
Senior Member

Joined: Fri Dec 10, 2010 6:21 am
Posts: 144
What about "sudo -s"? Iirc that doesn't switch to the shell specified for the target user as opposed to su...

Don't really know what's going on there, though. Does it actually now say that "/sbin/nolong" doesn't exist even though you changed root's shell to "/sbin/nologin"?


Top
   
 Post subject:
PostPosted: Tue Apr 05, 2011 6:09 am 
Offline
Newbie

Joined: Tue Apr 05, 2011 5:19 am
Posts: 3
@hawk7000

Yes it says that it does not exist, even though I set the shell for the user (root in this case).

I booted into recovery, added user onestp to the sudoers list, but now it still says that user onestp is not in the sudoers list.

Something seems so wrong here. I am booting into recovery again, attempting to add the user to the sudoers list. While I am at it I will also change the user onestp's shell to /bash/bin in the hope that I can further fix this issue.

Will let you know what the outcome is. Thank you

Regards,
Simon


Top
   
 Post subject:
PostPosted: Tue Apr 05, 2011 6:20 am 
Offline
Newbie

Joined: Tue Apr 05, 2011 5:19 am
Posts: 3
I finally solved my issue. It was silly, but here was my issuse:

When logging into the recovery console, I had to mount the /dev/xvda to /media/xvda

HOWEVER, when I was running my commands such as sudo nano /etc/passwd, they were running relative to the RECOVERY IMAGE root and NOT my mounted location.

So, while in the location /media/xvda I ran sudo nano etc/passwd and changed the shell back to /bin/bash for root.

All is well now, and SSH access as root has been restored.

I hope this saves someone hours of trouble some day.


Top
   
 Post subject:
PostPosted: Tue Apr 05, 2011 12:18 pm 
Offline
Senior Member

Joined: Fri Jan 09, 2009 5:32 pm
Posts: 634
why are you coming into ssh as root? you should have this disabled in ssh.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: fos and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group