How to use openconnect to connect to vpn with 2 factor authentication with Google Authenticator
Asked Answered
A

2

9

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

Alphitomancy answered 3/8, 2020 at 15:38 Comment(0)
A
6

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>
Alphitomancy answered 3/8, 2020 at 15:38 Comment(0)
D
4

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.

Demineralize answered 23/9, 2020 at 8:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.