Great question — answering as the UphillTech team:
You should avoid scripting the yes response to the certificate prompt. If OpenConnect is asking you to confirm the server certificate, the safer approach is to explicitly pin the server certificate using --servercert , rather than accepting it interactively every time. First, connect manually once and let OpenConnect show you the certificate fingerprint. It usually prints a value like: pin-sha256:... Then use that value explicitly: printf '%s\n' 'mypassword' | sudo openconnect serveraddress \ --user="myuser" \ --passwd-on-stdin \ --servercert pin-sha256:YOUR_PIN_HERE That way, only the password is passed through stdin, and the server identity is verified through the pinned certificate. If...
Full answer by Sorin-Doru Ipate: https://askubuntu.stackexchange.com/a/1567751 (CC BY-SA 4.0).
Need it done for your business? UphillTech.