#!/bin/bash set -e ssh-keygen -A grep -q "^PermitRootLogin" /etc/ssh/sshd_config && \ sed -i "s/^PermitRootLogin.*/PermitRootLogin no/" /etc/ssh/sshd_config || \ echo "PermitRootLogin no" >> /etc/ssh/sshd_config grep -q "^PasswordAuthentication" /etc/ssh/sshd_config && \ sed -i "s/^PasswordAuthentication.*/PasswordAuthentication yes/" /etc/ssh/sshd_config || \ echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config echo "AllowUsers ctf" >> /etc/ssh/sshd_config /usr/sbin/sshd if [ -n "$FLAG" ]; then echo "$FLAG" > /flag.txt chmod 644 /flag.txt chown root:root /flag.txt fi exec su -c "cd /home/ctf/chall/src && ./run.sh" -s /bin/bash ctf