Skip to content

Instantly share code, notes, and snippets.

@vvavrychuk
Last active August 5, 2022 03:44
Show Gist options
  • Save vvavrychuk/8bf49d06e6f89db69315c7dc708acdc9 to your computer and use it in GitHub Desktop.
Save vvavrychuk/8bf49d06e6f89db69315c7dc708acdc9 to your computer and use it in GitHub Desktop.
Connecting to Cisco AnyConnect VPN using connman

It is possible to connect to Cisco AnyConnect VPN using connman.

First of all connman-vpn should be installed:

apt install connman connman-vpn
systemctl disable NetworkManager

Later is required because it is not possible to completely remove NetworkManager because too many packages depend on it.

Write provision file /var/lib/connman-vpn/name.config, where name is a provision file name and it is given by you. Content of this file should be

[global]
Name = VPN name, for example "My Company VPN" (without quotes)

[provider_oc]
Type = OpenConnect
Name = VPN Provider name, for example "My Company Cisco VPN" (without quotes)
Host = VPN IP address
Domain = VPN Host
Networks = network IP/mask
OpenConnect.ServerCert = sha256:...
OpenConnect.VPNHost = VPN Host

Execute authentification request to obtain server certificate (FINGERPRINT) and OpenConnect Cookie

openconnect --authenticate [--user username] "VPN host"

Run connman client, connmanctl and perform following actions. Register agent

connmanctl> vpnagent on

List available services, among them you should find VPN service

connmanctl> services

Connect

connmanctl> connect vpn_service_path
OpenConnect Cookie?
OpenConnect server certificate hash?
OpenConnect VPN server?
Connected vpn_service_path

After entering OpenConnect Cookie connection should success. For OpenConnect server certificate hash and OpenConnect VPN server you can just press Enter since this values are already specified in provision file.

After that opposite to our service in the service list you should find R (ready) indication

connmanctl> services
* R Service Name service_path

Disconnect

connmanctl> disconnect service_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment