Last active
September 17, 2021 01:42
-
-
Save mikecharles/434968764a9048c01162641eb958200b to your computer and use it in GitHub Desktop.
Start and stop OpenConnect VPN
This file contains hidden or 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 python | |
from subprocess import call, PIPE | |
import os | |
user = '<user>' | |
vpn_servers = ['<server1>', '<server2>'] | |
for vpn_server in vpn_servers: | |
# Test server first | |
response = call('ping -c 1 -W 2 {}'.format(vpn_server), shell=True, stdout=PIPE) | |
if response == 0: | |
p = call(['sudo', 'openconnect', '-b', '--no-cert-check', '--user=' + user, vpn_server]) |
This file contains hidden or 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
#!/bin/sh | |
sudo kill -s SIGINT $(pgrep openconnect) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment