commit bf26c46b48989903a251994230ec8d89d9d9e20c Author: Zsolt Alföldi Date: Tue Jul 22 16:07:01 2025 +0200 saving diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..b2c6925 --- /dev/null +++ b/.env.example @@ -0,0 +1,4 @@ +PEM_PASS=pass.. +VPN_USER=zsolt.alfoldi@nokia.com +VPN_USER_PASS=saaapp... + diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..2d594a7 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +export $(cat .env | grep -v '#' ) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env diff --git a/run.exp b/run.exp new file mode 100755 index 0000000..b10d5e3 --- /dev/null +++ b/run.exp @@ -0,0 +1,43 @@ +#!/usr/bin/expect -f +# +# Usage: +# vpn-auto.exp +# +# Example: +# ./vpn-auto.exp PEM_PASS VPN_USER VPN_PASS MS_AUTH_OTP +# ./vpn-auto.exp pass1234 zsolt.alfoldi@nokia.com 1234pass 987456 + +# never timeout +set timeout -1 + +# pull args off the command line +if { $argc != 4 } { + puts stderr "Usage: $argv0 " + exit 1 +} +lassign $argv vpn_pem_pass vpn_user vpn_pass otp + +# start the connection +spawn nmcli connection up Nokia --ask + +# watch for the prompts and supply answers +expect { + -re "Enter PEM pass phrase" { + send "$vpn_pem_pass\r" + exp_continue + } + -re "Username:" { + send "$vpn_user\r" + exp_continue + } + -re "PASSCODE:" { + send "$vpn_pass\r" + exp_continue + } + -re "Response:" { + send "$otp\r" + exp_continue + } + eof +} + diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..00d36f7 --- /dev/null +++ b/run.sh @@ -0,0 +1,9 @@ +#!/bin/env bash + +# example run: +# sudonix run.sh 908029 + +expect run.exp $PEM_PASS $VPN_USER $VPN_USER_PASS $1 + +sudo ip route add 10.0.0.0/8 dev vpn0 +