Last active
January 11, 2016 20:49
-
-
Save TikiTDO/342db00caf67b1249afa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Note: This is a joke. If you actually run this script, then I will laugh, and you will deserve whatever happens. | |
user=`whoami` | |
# Must be run as root | |
if [ $user != 'root' ]; then | |
echo "This script must be run as root. Aborting." | |
exit 1; | |
fi | |
# Must have apt-get | |
command -v apt-get >/dev/null 2>&1 || { echo >&2 "This script requires apt-get. Aborting."; exit 1; } | |
# Install the google authenticator pam library | |
apt-get install libpam-google-authenticator | |
# Do very silly stuff. This (probably) kills the computer. | |
if [ `grep /etc/pam.d/ssh 'pam_google_authenticator'` == "" ]; then | |
{ echo 'auth required pam_google_authenticator.so '; cat /etc/pam.d/ssh; } > /etc/pam.d/ssh.new | |
mv /etc/pam.d/ssh.new /etc/pam.d/ssh | |
fi | |
# Do more stilly stuff. This (probably) kills the ssh server. | |
sed -i '/#?\s*ChallengeResponseAuthentication.*/ChallengeResponseAuthentication yes/' /etc/ssh/sshd_config | |
service ssh restart | |
if [ -z $SUDO_USER ]; then | |
sudo -u $SUDO_USER google-authenticator | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment