7

I would like to connect to vpn using openconnect. Our company uses Google Authenticator codes.

knb
  • 9,138
  • 4
  • 58
  • 85
vozman
  • 1,198
  • 1
  • 14
  • 19

2 Answers2

5

Use this to create 2 factor codes on your pc https://github.com/arcanericky/ga-cmd
Store your account password in ~/.cisco/pass.txt

Then use this to connect to vpn

echo -e "$(sudo cat ~/.cisco/pass.txt)\n$(./ga-cmd <your-ga-site-name>)" | sudo openconnect --user=<username> --passwd-on-stdin <your-vpn.com>
vozman
  • 1,198
  • 1
  • 14
  • 19
3

Or you can make it working with oathtool (works fine for macOS users):

alias vpn="echo -e '${YOUR_PWD}\n$(cat ~/.totp_google | xargs oathtool --totp -b)' | \
  sudo openconnect {YOUR_VPN_HOST} --user=${YOUR_USERNAME} --passwd-on-stdin"

Your secret shoud be in ~/.totp_google file.

mirabilos
  • 5,123
  • 2
  • 46
  • 72
Dzmitry Hubin
  • 1,091
  • 12
  • 14