Friday, February 13, 2015

Cisco VPN on Linux, with free software

Many companies and schools use a VPN solution from Cisco.
While the client on Windows is fine, the Linux version does nasty stuff such as creating copies and aliases of the /etc/hosts file. Also, I don't like running closed-source software with root privileges.
The third reason not to use Cisco VPN Client on Linux: you can't manage it with the package manager.

There's an open source alternative called openconnect.

I've written two aliases:

1) vpnc initiates the session, then goes to the background. You can close the terminal.
2) vpnd disconnects your from the VPN network.

Put this in your ~/.bash_aliases or whatever:

alias vpnc='echo Your_Password | sudo openconnect vpn_server_adress.domain.com --authgroup="AuthGroup as displayed on Cisco VPN client" --user=Your_Username --passwd-on-stdin --background'
alias vpnd='sudo pkill openconnect'

You can also put your password in a file, chmod 400 it, and use "cat my_file" instead of "echo Your_Password".
If you think don't like my pkill solution, you can use openconnect's "--pid-file" argument.

There you have it. Your friends using Cisco VPN client will envy you so much. 4 characters and you are connected!

No comments:

Post a Comment