Skip to content

Instantly share code, notes, and snippets.

@HungYuHei
Created July 21, 2012 13:06
Show Gist options
  • Save HungYuHei/3155786 to your computer and use it in GitHub Desktop.
Save HungYuHei/3155786 to your computer and use it in GitHub Desktop.
Create A Restricted User
#!/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