Restricted Bash rbash

Solution 1:

There is a reason you were given a restricted shell. If you were intended to be able to run all commands you would have been given a standard shell.

You should be able to run anything in the PATH you were given without starting the command with /. It is common to exclude commands which can be used to start an unrestricted shell from the path of users with a restricted shell.

EDIT: You have full access to any programs on your path. Some of theses may have commands which provide an unrestricted shell. Editors commonly have shell escape commands. Other commands may provide access to an unrestricted shell When creating a path for a restricted shell verify the capabilities of each command on the path. Giving people the ability to write any files on the path provides an obvious risk.

Restricted shells provide protection to both the system and the user. The system is protected because the user should not have much access to destructive commands. The user is protected damage done to the system using commands not on the path are likely not done by the user. The system manager should be responsible for ensuring the commands on the path do not provide unrestricted shell access.

Solution 2:

Here is what worked for me when I faced rbash:

BASH_CMDS[a]=/bin/sh;a
export PATH=/bin:/sbin:/usr/bin:$PATH