File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # The below is run as root user (or sudo user) and tested on Ubuntu Machine
4+
5+ # Create a User with restricted bash shell
6+ useradd -s /bin/rbash -m " $USERNAME "
7+ mkdir /home/" $USERNAME " /.ssh/
8+
9+ # Copy the pubkeys here and change permissions
10+ cd /home/" $USERNAME " /
11+ cat /tmp/" $PUBLIC_KEY " >> .ssh/authorized_keys
12+ chmod 0700 .ssh/
13+ chown -R " $USERNAME " :" $USERNAME " .ssh
14+
15+ # remove temp keys
16+ # Add command symlinks to the user private bin dir
17+ cd /home/" $USERNAME "
18+ mkdir bin
19+
20+ ln -s /bin/ls /home/" $USERNAME " /bin/
21+ ln -s /usr/bin/top /home/" $USERNAME " /bin/
22+ ln -s /usr/bin/du /home/" $USERNAME " /bin/
23+ ln -s /bin/date /home/" $USERNAME " /bin/
24+ ln -s /bin/uname /home/" $USERNAME " /bin/
25+ ln -s /usr/bin/free /home/" $USERNAME " /bin/
26+ ln -s /usr/bin/head /home/" $USERNAME " /bin/
27+ ln -s /usr/bin/tail /home/" $USERNAME " /bin/
28+ ln -s /usr/bin/less /home/" $USERNAME " /bin/
29+ ln -s /bin/more /home/" $USERNAME " /bin/
30+ ln -s /bin/cat /home/" $USERNAME " /bin/
31+ ln -s /bin/ping /home/" $USERNAME " /bin/
32+ ln -s /usr/bin/telnet /home/" $USERNAME " /bin/
33+
34+ # Update path and deny path editing for "$USERNAME"
35+ cd /home/" $USERNAME "
36+ sed -i ' /^PATH/s/PATH.*/PATH=\$HOME\/bin/g' .profile
37+ sed -i ' /^PATH/s/PATH.*/PATH=\$HOME\/bin/g' .bashrc
38+ chattr +i .bashrc .profile
You can’t perform that action at this time.
0 commit comments