Skip to content

Instantly share code, notes, and snippets.

@shivanshuag
Last active August 29, 2015 14:07
Show Gist options
  • Save shivanshuag/a600cb1c0b2b142f27c8 to your computer and use it in GitHub Desktop.
Save shivanshuag/a600cb1c0b2b142f27c8 to your computer and use it in GitHub Desktop.
OpenVpn Multi Factor Authentication Script
#!/usr/bin/perl
#OpenVpn Multi Factor Authentication Script
#Compares the password to "bar"
use POSIX;
# Get username/password from file
if ($ARG = shift @ARGV) {
if (!open (UPFILE, "<$ARG")) {
print "Could not open username/password file: $ARG\n";
exit 1;
}
} else {
print "No username/password file specified on command line\n";
exit 1;
}
$username = <UPFILE>;
$password = <UPFILE>;
$password_cmp = "bar";
if (!$username || !$password) {
print "Username/password not found in file: $ARG\n";
exit 1;
}
chomp $username;
chomp $password;
close (UPFILE);
exit !($password eq $password_cmp);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment