Created
July 21, 2012 13:06
-
-
Save HungYuHei/3155786 to your computer and use it in GitHub Desktop.
Create A Restricted User
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
username="user_name" | |
cp -a /bin/bash /bin/rbash | |
useradd -c "A Restricted User" -d /home/$username -s /bin/rbash $username | |
rm -rf /home/$username | |
mkdir -m 555 /home/$username | |
mkdir -m 555 /home/$username/bin | |
cp -a /bin/ls /home/$username/bin | |
cp -a /usr/bin/passwd /home/$username/bin | |
echo "export PATH=/home/$username/bin" > /home/$username/.bash_profile | |
chmod 444 /home/$username/.bash_profile | |
passwd $username |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment