Created
June 14, 2016 16:30
-
-
Save mgax/9383f53d3d4ecbc6a60302a9a65d7076 to your computer and use it in GitHub Desktop.
VPN client-server setup with username and password login
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 | |
set -e | |
args=( | |
/usr/sbin/openvpn | |
--client | |
--proto udp | |
--remote 192.168.2.10 30335 | |
--dev tun | |
--tls-client | |
--ns-cert-type server | |
--ca ca.crt | |
--auth-user-pass | |
) | |
set -x | |
exec "${args[@]}" |
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
#!/usr/bin/env python | |
import sys, os | |
ACCOUNTS = { | |
'a': 'b', | |
} | |
def login(username, password): | |
with open('auth.log', 'ab') as f: | |
print>>f, "username:", username, "password:", password | |
return ACCOUNTS.get(username) == password | |
if login(os.environ.get('username'), os.environ.get('password')): | |
sys.exit(0) | |
else: | |
sys.exit(1) |
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 | |
set -e | |
args=( | |
/usr/sbin/openvpn | |
--cd /var/local/vpn-server | |
--proto udp | |
--port 30335 | |
--dev tun0 | |
--server 10.100.0.0 255.255.255.0 | |
--auth-user-pass-verify ./login.py via-env | |
--script-security 3 | |
--client-cert-not-required | |
--username-as-common-name | |
--tls-server | |
--dh dh2048.pem | |
--ca keys/ca.crt | |
--cert keys/server.crt | |
--key keys/server.key | |
) | |
set -x | |
exec "${args[@]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment