Skip to content

Instantly share code, notes, and snippets.

@mootinator
Last active November 19, 2020 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mootinator/1d2870d2ba55d7173ea3ad9d3ca827ef to your computer and use it in GitHub Desktop.
Save mootinator/1d2870d2ba55d7173ea3ad9d3ca827ef to your computer and use it in GitHub Desktop.
Use sexpect to initiate OpenVPN connection which uses DUO mobile from router.
#!/bin/sh
if ! which sexpect >& /dev/null; then
echo "sexpect not found in your \$PATH"
exit 1
fi
export SEXPECT_SOCKFILE=/tmp/sexpect-openvpn-aa0.sock
sexpect spawn openvpn --config /root/client.ovpn
sexpect expect -re 'Enter Auth Password:'
sexpect send -enter `cat /root/password2.txt`
sexpect expect -re '^.*CRV1:R,E:([A-Za-z0-9+/=]+).*$'
out=`sexpect expect_out -index 1`
sexpect expect -re 'Enter Auth Password:'
sexpect send -enter CRV1::$out::push
sexpect interact
@mootinator
Copy link
Author

Sexpect binary tests successfully on OpenWRT on a TP-LINK Archer C7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment