is_debian && mkdir -p /run/sshd T=$(sshd -T 2>/dev/null) SSHOPT=(-o BatchMode=yes -o ConnectTimeout=5 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR) # key_login USER [ssh options]: USER logs in with their lab key and runs a command. key_login() { local u=$1; shift; timeout 15 ssh "${SSHOPT[@]}" -i /root/lab-keys/$u "$@" $u@localhost 'echo le-shell-ok' /tmp/le-lab-ssh.out; grep -qx alice /tmp/le-lab-ssh.out && grep -q " 10\.99\.0\.2/" /tmp/le-lab-ssh.out' rm -f /tmp/le-lab-ssh.out task 4 "curl localhost:8080 reaches the peer's web server through a tunnel" need "curl localhost:8080 returns the peer's page" 'curl -s --max-time 5 http://localhost:8080/ | grep -q "Peer web server"' task 5 "Group sftponly: SFTP only, chrooted in /srv/sftp/" need "sam can log in with sftp" 'echo pwd | sam_sftp' need "sam's sftp starts in a chroot at /srv/sftp/sam" 'echo pwd | sam_sftp | grep -q "Remote working directory: /$"' need "sam can write in /srv/sftp/sam/upload" 'f=le-check-$$; echo "put /etc/hostname upload/$f" | sam_sftp && [ -f /srv/sftp/sam/upload/$f ]; r=$?; rm -f /srv/sftp/sam/upload/$f; exit $r' need "ssh as sam gives no shell" '! key_login sam'