Last active
March 25, 2020 00:35
-
-
Save Baccata/7330ce6962c0d650c3061d4050fe548b to your computer and use it in GitHub Desktop.
Script to query pwd from lastpass and feed it to the vpn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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/*****/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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