build

TU Berlin VPN for Linux

Tray app · openconnect + NetworkManager

Connecting to the TU Berlin VPN on Linux used to be a fight with Cisco's client. Now it's one click in the tray, 2FA included.

  • Worked out what the server expects: embedded SSO browser, Cisco user agent, no group in the request
  • Runs without sudo by handing the session cookie to NetworkManager

Why

Cisco’s VPN client and Linux don’t get along, so connecting to the uni VPN was a hassle every single time. I built a tray app that does it with the open-source openconnect instead. Now it’s one click, and a few friends use it too.

Convincing a picky server

openconnect speaks the same protocol as Cisco’s client, but the TU server is picky about who it talks to. Getting in meant figuring out its quirks one 404 at a time:

  • SSO only in an embedded browser. The 2FA profiles use SAML single sign-on, and the server only offers it to an embedded browser, so the app reuses the WebKit login window that ships with networkmanager-openconnect.
  • A Cisco user agent. With openconnect’s default user agent, the server answers 404 and falls back to a form that can’t do 2FA.
  • No group in the request. Sending one also gives a 404; the default group is preselected in the login window instead.
  • NVIDIA + Wayland. WebKitGTK can stop redrawing, which makes the login look frozen. Two environment variables fix it.
  • No sudo. The session cookie goes to NetworkManager, which runs openconnect itself. That only works if the profile’s secrets are marked as not saved.

How it’s built

DESKTOPTU BERLINsingle sign-onSYSTEMno sudoTU BERLINVPNTray appPyQt6 · status +disconnectLogin windowWebKit · fromnm-openconnectSSO loginpassword + TANNetworkManagersecrets not savedopenconnectCisco user agent,no groupVPN gatewayvpn.tu-berlin.de1connect2SAML3session cookie4AnyConnect
  1. 1One click in the tray opens the login window.
  2. 2The 2FA login runs as single sign-on in that embedded browser, the only way the server offers it, and ends with a session cookie.
  3. 3The app hands that cookie to NetworkManager instead of using it directly.
  4. 4NetworkManager starts openconnect with the right user agent, which is why no sudo is needed.
The login happens in an embedded browser; the session cookie then goes to NetworkManager, which runs openconnect, so nothing needs sudo.