Compare commits

..

No commits in common. "c382a06b50fd2b66cb4a72f7362a164349083ff1" and "50525dc1245927b3c4f95d8f0f75de9fc3b8e6ee" have entirely different histories.

View File

@ -4,19 +4,16 @@
CMDS="mkdir touch mv rm ls grep cat vim"
USER=$1
CHROOT=$(eval echo ~$USER)
CMDS=($CMDS) # convert to array
# Create user if not exist
if ! id "$USER" 2&>/dev/null; then
echo 'INFO: User not found'
echo 'Creating...'
useradd -m $USER
echo "Password for $USER:"
passwd $USER
printf "Match User $USER\n ChrootDirectory $CHROOT$CHROOT" >> /etc/ssh/sshd_config.d/70-$USER.conf
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
for cmd in "${CMDS[@]}"; do
for dep in $( ldd $(which $cmd) | grep -v dynamic | cut -d " " -f 3 | sed 's/://' | sort | uniq ); do
@ -26,7 +23,7 @@ for cmd in "${CMDS[@]}"; do
done
# cp user and group into chroot
mkdir -p $CHROOT/etc/
mkdir -p $CHROOT/etc
cat /etc/passwd | grep $USER > $CHROOT/etc/passwd
cat /etc/group | grep $USER > $CHROOT/etc/group