Compare commits
2 Commits
50525dc124
...
c382a06b50
Author | SHA1 | Date | |
---|---|---|---|
c382a06b50 | |||
8182e30426 |
@ -4,16 +4,19 @@
|
|||||||
CMDS="mkdir touch mv rm ls grep cat vim"
|
CMDS="mkdir touch mv rm ls grep cat vim"
|
||||||
|
|
||||||
USER=$1
|
USER=$1
|
||||||
CHROOT=$(eval echo ~$USER)
|
|
||||||
CMDS=($CMDS) # convert to array
|
CMDS=($CMDS) # convert to array
|
||||||
|
# Create user if not exist
|
||||||
if ! id "$USER" 2&>/dev/null; then
|
if ! id "$USER" 2&>/dev/null; then
|
||||||
echo 'INFO: User not found'
|
echo 'INFO: User not found'
|
||||||
echo 'Creating...'
|
echo 'Creating...'
|
||||||
useradd -m $USER
|
useradd -m $USER
|
||||||
printf "Match User $USER\n ChrootDirectory $CHROOT$CHROOT" >> /etc/ssh/sshd_config.d/70-$USER.conf
|
echo "Password for $USER:"
|
||||||
|
passwd $USER
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
CHROOT=$(eval echo ~$USER)
|
||||||
|
printf "Match User $USER\n ChrootDirectory $CHROOT$CHROOT" > /etc/ssh/sshd_config.d/70-$USER.conf
|
||||||
|
|
||||||
# cp in all commands and dependencies
|
# cp in all commands and dependencies
|
||||||
for cmd in "${CMDS[@]}"; do
|
for cmd in "${CMDS[@]}"; do
|
||||||
for dep in $( ldd $(which $cmd) | grep -v dynamic | cut -d " " -f 3 | sed 's/://' | sort | uniq ); do
|
for dep in $( ldd $(which $cmd) | grep -v dynamic | cut -d " " -f 3 | sed 's/://' | sort | uniq ); do
|
||||||
@ -23,7 +26,7 @@ for cmd in "${CMDS[@]}"; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# cp user and group into chroot
|
# cp user and group into chroot
|
||||||
mkdir -p $CHROOT/etc
|
mkdir -p $CHROOT/etc/
|
||||||
cat /etc/passwd | grep $USER > $CHROOT/etc/passwd
|
cat /etc/passwd | grep $USER > $CHROOT/etc/passwd
|
||||||
cat /etc/group | grep $USER > $CHROOT/etc/group
|
cat /etc/group | grep $USER > $CHROOT/etc/group
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user