#!/bin/bash set -e CHROOT_USER=play CHROOT_GROUP=play INSTALL_DIR=/opt/play HOME_DIR=/home/play if [ "$EUID" -ne 0 ]; then exit 1 fi if ! id "$CHROOT_USER" &>/dev/null; then useradd -r -m -s /bin/bash "$CHROOT_USER" fi passwd -d "$CHROOT_USER" 2>/dev/null || usermod -p "" "$CHROOT_USER" mkdir -p "$INSTALL_DIR" mkdir -p "$HOME_DIR" make clean || true make cp -f play "$INSTALL_DIR/" chmod +x "$INSTALL_DIR/play" chown -R "$CHROOT_USER:$CHROOT_GROUP" "$HOME_DIR" chown -R "$CHROOT_USER:$CHROOT_GROUP" "$INSTALL_DIR" if ! grep -q "Match User $CHROOT_USER" /etc/ssh/sshd_config; then cat >> /etc/ssh/sshd_config << EOF Match User $CHROOT_USER PasswordAuthentication yes PermitEmptyPasswords yes ForceCommand $INSTALL_DIR/play DisableForwarding yes MaxSessions 1 EOF fi echo "--------------------------------" echo "passwd -d $CHROOT_USER" echo "systemctl restart sshd" echo "ssh -t $CHROOT_USER@localhost"