CentOS 6 - user with limited commands and access - restricted bash

Add a user who can execute some specific commands. 
[1] Create a link named 'rbash' from bash.
[[email protected] ~]#
ln -s /bin/bash /opt/rbash
[2] Add a user that his default shell is rbash and set he can execute only 'ping'.
[[email protected] ~]#
useradd cern -s /opt/rbash

[[email protected] ~]#
passwd cern

[[email protected] ~]#
mkdir /home/cern/bin

[[email protected] ~]#
ln -s /bin/ping /home/cern/bin/ping

[[email protected] ~]#
chown root. /home/cern/.bash_profile

[[email protected] ~]#
chmod 755 /home/cern/.bash_profile

[[email protected] ~]#
vi /home/cern/.bash_profile
# change PATH like follows


[3] Login with the test user.
[[email protected] ~]$

-rbash: cd: restricted
# denied

[[email protected] ~]$

-rbash: ls: command not found
# none

[[email protected] ~]$
ping localhost

PING localhost ( 56(84) bytes of data.
64 bytes from localhost ( icmp_seq=1 ttl=64 time=0.045 ms
64 bytes from localhost ( icmp_seq=2 ttl=64 time=0.008 ms
64 bytes from localhost ( icmp_seq=3 ttl=64 time=0.008 ms
--- localhost ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2157ms
rtt min/avg/max/mdev = 0.008/0.020/0.045/0.017 ms
# executed

found at: http://www.server-world.info/en/note?os=CentOS_6&p=rbash


Popular posts from this blog

Securing the Pi-hole with fail2ban to prevent DNS Amplification attacks

How to clean DB from old logs in Magento 1.x

Python pxssh failed on login. could not set shell prompt