Developer Work From Home Tool!
AnyConnect is a VPN tool that many organizations use for their work computers. If you're like me and hate the process of waiting for the application to open, grabbing a security code (not required for everyone), waiting for the network to establish and blah blah blah, this tool can do all that from the command line.
Using a bash script with your credentials pre-filled, it will use AnyConnect's built-in CLI tool to connect to your company's VPN. You can modify this as you please.
If you do not want your password stored on your machine:
- Please uncomment lines 4 & 5, then comment line 7 & 8.
If you do not require a security code to login:
- Please comment out lines 3 & 9 and uncomment line 10.
Make sure to change "[YOUR-VPN-HOST-NO-BRACKETS]" to your VPN host on line 10.
Run in your terminal:
sh vpn.sh
That's it!
Run this command in your terminal:
sh vpn.sh
Then type "hosts" when prompted. From there you'll get a list of available hosts. Please refer to the Configuration section above for implementation.
v1.0.2
Your password must now be base64 encoded. This is done for security reasons, so that your password isn't sitting on your system in plain text. You can determine your the base64 string for your password by running this on your linux/unix system:
echo 'YOUR-PASSWORD-HERE' | base64
v1.0.1
Issue: Variable strings with "%" character.
Reason: printf is a shell built into Bash, similar to C printf(). printf uses special characters for string formatting. When a string contains a "%", that is not being used for formatting purposes, the printf command does not know how to handle it. Thus, requiring a specific format to instantiate the variable string.
Fix: Use the printf FORMAT [ARGUMENT] structure. i.e print "%s" $variable
v1.0.0
Initial release.
This Stackoverflow post will guide you step by step: Add bash script to PATH
If you want to collaborate on a code project, please send me an email (click me)