Skip to content

Instantly share code, notes, and snippets.

@Baccata
Last active March 25, 2020 00:35
Show Gist options
  • Save Baccata/7330ce6962c0d650c3061d4050fe548b to your computer and use it in GitHub Desktop.
Save Baccata/7330ce6962c0d650c3061d4050fe548b to your computer and use it in GitHub Desktop.
Script to query pwd from lastpass and feed it to the vpn
#!/usr/bin/env bash
HOST="???" # address of the vpn
LASTPASS_ENTRY="???" # entry under which the password is saved in last pass
USERNAME=$(lpass show --sync=auto --username $LASTPASS_ENTRY)
PASSWORD=$(lpass show --sync=auto --password $LASTPASS_ENTRY)
# escaping the special chars in the password to allow sed-ing it
ESC_PWD=$(echo $PASSWORD | sed -e 's/[]\/$*.^[]/\\&/g')
echo "connecting to $HOST vpn as $USERNAME"
printf "${USERNAME}\n${PASSWORD}\ny" | /opt/cisco/anyconnect/bin/vpn -s connect $HOST | sed "s/$ESC_PWD/*****/"
#!/usr/bin/env bash
/opt/cisco/anyconnect/bin/vpn disconnect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment