Connect CISCO Anyconnect VPN via bash

前端 未结 5 1653
滥情空心
滥情空心 2020-12-25 08:52

As title says, trying to connect vpn via bash. The following script seemed closest to the answer I\'m looking for:

#!/bin/bash
/opt/cisco/anyconnect/bin/vpn          


        
5条回答
  •  眼角桃花
    2020-12-25 09:27

    Although expect can be cleaner, it is not strictly necessary. Assuming /opt/cisco/anyconnect/bin/vpnagentd is running as it automatically should be:

    To connect:

    printf "USERNAME\nPASSWORD\ny" | /opt/cisco/anyconnect/bin/vpn -s connect HOST
    

    Replace USERNAME, PASSWORD, and HOST. The \ny at the end is to accept the login banner - this is specific to my host, and so you may not need it.

    I understand that there are obvious security concerns with this method; it's for illustration purposes only.

    To get state:

    /opt/cisco/anyconnect/bin/vpn state
    

    To disconnect:

    /opt/cisco/anyconnect/bin/vpn disconnect
    

    This was tested with AnyConnect v3.1.05160.

提交回复
热议问题