1

There is an option in whm/cpanel to enable jailshell access for any hosting account.

I want to know if it is possible to enable that option for any or all cpanel hosting accounts through command line.

1 Answer 1

2
+50

Jailshell can be enabled for a user in WHM by navigating to Manage Shell Access under Account Functions.

To setup jailshell access for a user from the command line interface, simply use the operating system's change shell command as root, for example:

# username=CPANELUSERNAME;
# chsh -s /usr/local/cpanel/bin/jailshell ${username}

You may also be interested in these sections of cPanel's documentation:


Remember:

${username} and $username both refer to a local variable called username.

Suppose your username is fahad.

If you want to change the shell without using the variable, it would look like this:

# chsh -s /usr/local/cpanel/bin/jailshell fahad

If you typed chsh -s /usr/local/cpanel/bin/jailshell ${username} without setting the variable username first, it would be equivalent to ch -s /usr/local/cpanel/bin/jailshell without any parameter after to designate the user whose shell you want to change, and then the command defaults to changing the shell for the currently logged in user.

You also said that you're getting this error:

 '0' is not a valid user id, and may not run jailshell (cpanel users file missing).

That is caused because the root account has been set to use jailshell, though it should not be. This could have happened when you executed the above command without passing the parameter for the user account (i.e. by using an unset variable).

You may wish to reset your shell to /bin/bash in WHM by navigating to Manage Shell Access under Account Functions. Alternatively, if you are comfortable doing so, you can edit the change is in the /etc/password file manually by running vipw (as the file cannot be edited directly easily under most systems).

8
  • I have tried from root user chsh -s /usr/local/cpanel/bin/jailshell ${username} replaced {username} to {my cpanel user name} but it changed my root to jail shell. Now when I login by root id it gives me this error '0' is not a valid user id, and may not run jailshell (cpanel users file missing). and also I am getting this prompt -jailshell-4.1# Apr 18, 2014 at 18:38
  • I updated my answer. Hope that helps. Apr 18, 2014 at 18:48
  • I have created a ticket on my hosting support regarding this issue but they are saying ""This broke root. Using this command improperly from the command line has caused root to be put into a jailed shell. The only way to restore this is to do a vps restore."" Is there any way we can restore root user shell access to normal without restoring the VPS ?? Apr 18, 2014 at 20:38
  • If your VPS provider supports it, you may be able to reboot the VPS into single user mode or using a recovery kernel. Apr 18, 2014 at 20:49
  • Someone in your position was able to recover via SU mode. Apr 18, 2014 at 20:58

Not the answer you're looking for? Browse other questions tagged .