Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logging in as root via SSH when using chroot 2

Status
Not open for further replies.

bazil2

Technical User
Feb 15, 2010
148
DE
(Elementary User)

In order to use chroot, I followed the following steps from the RHL knowledgebase:


# adduser jack

# mkdir /chroot
Create user's home directory, which will be actually '/' directory after user login.

# mkdir -p /chroot/home/jack
Copy all the files that the user needs including basic commands like 'ls', libraries and /dev files.

# mkdir /chroot/home/jack/bin
# cp -a /bin/bash /chroot/home/jack/bin/.
# cp -a /bin/ls /chroot/home/jack/bin/.
# cp -a /lib64 /chroot/home/jack/.
Edit /etc/ssh/sshd_config file

ChrootDirectory /chroot/%h
Restart sshd

# service sshd restart
# chkconfig sshd on

After undertaking this, the user jack was jailed as intended, however, can anyone please advise the correct procedure for being able to login as root?

Can anyone please advise, is there a way of switching to the user root or must one also create (like jack) a root folder in chroot?

Best regards


 
After undertaking this, the user jack was jailed as intended, however, can anyone please advise the correct procedure for being able to login as root?

Can anyone please advise, is there a way of switching to the user root or must one also create (like jack) a root folder in chroot?
Why would you want to login to SSH as root? This is not a safe practice, even in a CHROOT jail (which can be broken). It would be much better for you to use either SU or SUDO to assume root privilege after you login as a non privileged user.
 
Many thanks,

Could you please advise as to how I could enable the user 'jack' to be able to use SU or SUDO

Many thanks
 
There is a sudo users file, /etc/sudoers. You don't want to try to edit this file directly, though. Instead use the command visudo. You will need to add the user jack to the sudoer's file and give them appropriate permissions, typically ALL, but you have the option of using refined control.

The Ubuntu wiki page has about the best how-to on the subject I've seen. Sudo is generic and this should work on any distribution. Here is a link:
Once you have done this, when operating as Jack, you can prefix a privileged command with sudo, you will be prompted for JACK'S password.
To bring up a root level prompt without having to prefix every command you can then use 'sudo -i', with JACK's password.

Otherwise, if you have a root account you can use use 'su -' to switch to user root, and use the ROOT password.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top