# VPN Seamless Auto Connect ## _Easiest way to connect to VPN using Docker Container together with Surge for Mac_ ## Pre-requisite Important tools to work properly: - [Brew] - to install stoken - [stoken] - to retrieve SecureID token - [sdtid file] - (VPN token file for SecureID Mobile): to be imported to stoken - [Docker Desktop] - running your docker container - [Docker Image] - container to run your open-connect vpn inside docker container - [Surge for Mac] - tunnelling your network traffic to docker container And of course you need to backup your existing proxies in the network setting. Recommended to use the same proxies in Surge for Mac. ## Installation _Optional_: Install HomeBrew package manager if not yet available in your machine ```sh /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` Install stoken from HomeBrew ```sh brew install stoken ``` Import your sdtid file (make sure terminal open in the same directory with the sdtid file) ```sh stoken import --file=459XXX_000725157769.sdtid ``` Retrieve your SecureID tokencode - !Important to set your decrypt password same as your VPN PIN (will prompt after executed below command) - PIN = Your own PIN before six digit SecureID token in the mobile to be use during VPN login - Example: <PIN>658292 ```sh stoken tokencode ``` - kindly cross-check your token with your SecureID app in your mobile device ## Docker Make sure your Docker Desktop up and running Download docker image here: https://drive.google.com/file/d/15cvbu6IWa4v7RnV2AbWN6kJFT6x-HlOL/view?usp=share_link ```sh gunzip docker-openconnect-proxy.tar.gz docker load < docker-openconnect-proxy.tar ``` ## Surge for Mac * Is a tool for routing your network traffic to your proxy server * Our Docker Container is our own local proxy server with connection to the vpn (internal network) 1. Set Surge for Mac as System Proxy 2. Enhance mode will force your desktop app to tunnel its traffic to Surge 3. Create a new Proxy Policy (VPN) which uses your localhost (127.0.0.1) and using SOCKS5 protocol 4. Set RULE for internal network domain or IP to use Proxy Policy (VPN) ## Script This is where the magic happen 🙌 Download base script here: https://drive.google.com/file/d/1Db_0n9pkfaFu8iAiGpKAZkNomfjD2GaP/view?usp=share_link 1. Open vpn file using your editor (VSCode) 2. Edit the variable value such as PIN, Password and Your Staff ID (USERNAME) 3. Move the vpn file into your /scripts folder 4. Create /scripts folder if not have one yet. 5. Change vpn file permission to 755 (read execute for all but only writable to owner) ```sh chmod 755 vpn ``` _Set Env Path_ 1. Open .zshrc file 2. Add - export PATH=$PATH:~/scripts 3. Restart your terminal or run: ``` source .zshrc ``` !! _Complete_ !! Tada!! You are now have a one word to connect to your vpn ```sh vpn ``` ## _Thanks and Have a Good Day_ ** Enjoy, We Rock 🤟. Yeah!**