Skip to content

Instantly share code, notes, and snippets.

@dillera
Created February 20, 2012 22:17
Show Gist options
  • Save dillera/1871871 to your computer and use it in GitHub Desktop.
Save dillera/1871871 to your computer and use it in GitHub Desktop.
Create a chrooted user using mkchroot.sh
#/bin/bash
# andrew_diller
# 2012
# Note: this uses the 'rsshusers' group that is used by the rssh binary.
# Prerequisite: install rssh package!
# $ sudo yum -y install rssh
# Note: assumes you have downloaded and put the mkchoot.sh script in /root/mkchroot.sh
USER=$1
BASEDIR=/root
if [ -f ${BASEDIR}/mkchroot.sh ]; then
echo mkchroot exists!
else
echo "mkchroot not found, download and put into /root"
exit 1
fi
if [ `whoami` != "root" ]; then
echo "You are not root."
echo "Exiting"
exit 1
else
useradd -g rsshusers -p |__mypassword__| ${USER}
chsh -s /usr/bin/rssh ${USER}
${BASEDIR}/mkchroot.sh /chroot/${USER} ${USER} 2775 rsshusers
chmod u+s /usr/libexec/rssh_chroot_helper
fi
echo --------------------------------------------------------------
echo done for ${USER}
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment