Skip to content

Instantly share code, notes, and snippets.

@raevilman
Last active October 9, 2022 11:47
Show Gist options
  • Select an option

  • Save raevilman/6c5cfd47eeb8c83458cde946e33a4cba to your computer and use it in GitHub Desktop.

Select an option

Save raevilman/6c5cfd47eeb8c83458cde946e33a4cba to your computer and use it in GitHub Desktop.

Revisions

  1. raevilman revised this gist Sep 6, 2019. 1 changed file with 7 additions and 10 deletions.
    17 changes: 7 additions & 10 deletions setup.md
    Original file line number Diff line number Diff line change
    @@ -79,20 +79,17 @@ _Got below error_
    openconnect: /usr/lib/x86_64-linux-gnu/libopenconnect.so.5: version `OPENCONNECT_5_5' not found (required by openconnect)
    ```

    Found issue at below link
    Issue can be from one of the below links
    https://github.com/dlenski/openconnect/issues/130
    https://github.com/dlenski/openconnect/issues/56

    Above issue solved using below command
    Above issue solved using below

    If below command
    ```
    ldd /usr/local/sbin/openconnect
    ```
    shows 'libopenconnect.so.5 => not found' in the output
    then use below command
    ```sudo ldconfig```
    else ```sudo apt autoremove```
    If the command ```ldd /usr/local/sbin/openconnect```
    shows ```libopenconnect.so.5 => not found``` in the output
    then use command ```sudo ldconfig```
    else use ```sudo apt autoremove```
    to solve the issue


    Try connecting again
  2. raevilman revised this gist Sep 6, 2019. 1 changed file with 11 additions and 6 deletions.
    17 changes: 11 additions & 6 deletions setup.md
    Original file line number Diff line number Diff line change
    @@ -80,14 +80,19 @@ openconnect: /usr/lib/x86_64-linux-gnu/libopenconnect.so.5: version `OPENCONNECT
    ```

    Found issue at below link
    https://github.com/dlenski/openconnect/issues/130
    https://github.com/dlenski/openconnect/issues/56
    https://github.com/dlenski/openconnect/issues/130
    https://github.com/dlenski/openconnect/issues/56

    Above issue solved using below command
    Above issue solved using below command

    If this command ('ldd /usr/local/sbin/openconnect') shows 'libopenconnect.so.5 => not found' in the output
    then use this command 'sudo ldconfig'
    else 'sudo apt autoremove'
    If below command
    ```
    ldd /usr/local/sbin/openconnect
    ```
    shows 'libopenconnect.so.5 => not found' in the output
    then use below command
    ```sudo ldconfig```
    else ```sudo apt autoremove```


    Try connecting again
  3. raevilman revised this gist Sep 6, 2019. 1 changed file with 7 additions and 3 deletions.
    10 changes: 7 additions & 3 deletions setup.md
    Original file line number Diff line number Diff line change
    @@ -81,11 +81,15 @@ openconnect: /usr/lib/x86_64-linux-gnu/libopenconnect.so.5: version `OPENCONNECT

    Found issue at below link
    https://github.com/dlenski/openconnect/issues/130
    https://github.com/dlenski/openconnect/issues/56

    Above issue solved using below command
    ```
    sudo apt autoremove
    ```

    If this command ('ldd /usr/local/sbin/openconnect') shows 'libopenconnect.so.5 => not found' in the output
    then use this command 'sudo ldconfig'
    else 'sudo apt autoremove'


    Try connecting again
    This time, got push notification on mobile for approval

  4. raevilman revised this gist May 27, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion setup.md
    Original file line number Diff line number Diff line change
    @@ -71,7 +71,7 @@ sudo make install //to install the library

    On trying to connect to VPN using below command
    ```
    sudo openconnect --protocol=gp vpn.rms.com
    sudo openconnect --protocol=gp vpn.company.com
    ```

    _Got below error_
  5. raevilman revised this gist Apr 25, 2019. 2 changed files with 218 additions and 1 deletion.
    92 changes: 92 additions & 0 deletions oc_helper.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,92 @@
    #! /bin/bash

    # Copied from https://gist.github.com/rtgibbons/ae083457d0962bd3fe3f

    ### BEGIN INIT INFO
    # Provides: openconnect
    # Required-Start: $local_fs $remote_fs $network
    # Required-Stop: $local_fs $remote_fs $network
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Basic script to connect to a SSL VPN using Openconnect
    ### END INIT INFO

    # Define PATH
    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

    # VPN Variables
    HOST="https://##VPNURL##"
    USER="##USERNAME##"
    #PASS="PASSWORD"
    #CERT="/my/cert.pem"
    #KEY="/my/key.pem"

    # Set pidfile
    PIDFILE="/var/run/openconnect.pid"

    function start() {
    # Check if process is running. Exit in this case.
    [ -f ${PIDFILE} ] && ps -p $(< ${PIDFILE}) &> /dev/null && \
    echo "Openconnect is already running." && exit 0

    # Must be root
    [ ${UID} -ne 0 ] && echo "You must be root to run this script." && exit 1

    # Connect
    # For now if not on OSX ask for password on command prompt
    if [[ $(uname) == "Darwin" ]]; then
    VPN_PASS=$(osascript -e 'display dialog "RSA Password" default answer "" with title "OpenConnect VPN" with hidden answer' | awk -F'[:,]' '{print $4}')
    else
    stty -echo
    printf "Enter password to connect to VPN"
    read VPN_PASS
    stty echo
    printf "\n"
    fi

    openconnect --protocol=gp -b --user=${USER} ${HOST} --pid-file=${PIDFILE} --syslog --passwd-on-stdin <<< ${VPN_PASS}
    [ $? -ne 0 ] && echo "Openconnect failed to start!" && \
    rm -f ${PIDFILE} && exit 1
    }

    function stop() {
    if [ -f ${PIDFILE} ] && ps -p $(< ${PIDFILE}) &> /dev/null; then
    # Pid exists, kill process and remove pidfile
    [ ${UID} -ne 0 ] && echo "You must be root to run this script." && exit 1
    kill $(< ${PIDFILE}) && rm -f ${PIDFILE}
    else
    echo "Openconnect is not running!"
    fi
    }

    function status() {
    if [ -f ${PIDFILE} ] && ps -p $(< ${PIDFILE}) &> /dev/null; then
    echo "Openconnect is running."
    runningtime=$(ps -p $(< ${PIDFILE}) -o etime=)
    echo " IP: $(ifconfig | awk '/-->/{print $2}')"
    echo " $(ifconfig | awk -F': ' '/^utun/{print $1}'): ${runningtime}"

    else
    [ -f ${PIDFILE} ] && rm -f ${PIDFILE}
    echo "Openconnect is stopped."
    exit 3
    fi
    }

    case "$1" in
    start)
    start
    ;;
    stop)
    stop
    ;;
    status)
    status
    ;;
    restart)
    stop && start
    ;;
    *)
    echo "Usage: ${0##*/} (start|stop|status|restart)" && exit 0
    ;;
    esac
    127 changes: 126 additions & 1 deletion setup.md
    Original file line number Diff line number Diff line change
    @@ -1 +1,126 @@
    # Init
    # GlobalProtect on Ubuntu

    ### Major links followed
    Download
    https://www.infradead.org/openconnect/download.html

    Building OpenConnect
    https://www.infradead.org/openconnect/building.html

    Install vpnc-script
    https://www.infradead.org/openconnect/vpnc-script.html

    ---
    ### Steps to follow

    * Download the latest OpenConnect tar file from below ftp location and extract it
    ftp://ftp.infradead.org/pub/openconnect/

    * Run ```./configure``` command from within the extracted directory

    _Got below error_
    ```
    checking for functional NLS support... yes
    checking for GNUTLS... no
    checking for OPENSSL... no
    checking for OpenSSL without pkg-config... no
    configure: error: Could not build against OpenSSL
    ```

    Reason: The OpenSSL library is usually already installed, but you have to install the header files.

    So had to install same using below command
    ```
    sudo apt-get install libssl-dev
    ```

    Run ```./configure``` again

    _Got below error_

    ```
    checking for LIBXML2... no
    configure: error: in `/home/raman/Downloads/openconnect-8.02':
    configure: error: The pkg-config script could not be found or is too old. Make sure it
    is in your PATH or set the PKG_CONFIG environment variable to the full
    path to pkg-config.
    Alternatively, you may set the environment variables LIBXML2_CFLAGS
    and LIBXML2_LIBS to avoid the need to call pkg-config.
    See the pkg-config man page for more details.
    To get pkg-config, see <http://pkg-config.freedesktop.org/>.
    See `config.log' for more details
    ```

    Same as last error, I had to install libxml2-dev
    ```
    sudo apt-get install libxml2-dev
    ```

    Run ```./configure``` again
    This time command completes.

    ---
    Next

    ```
    sudo make
    sudo make install //to install the library
    ```

    On trying to connect to VPN using below command
    ```
    sudo openconnect --protocol=gp vpn.rms.com
    ```

    _Got below error_
    ```
    openconnect: /usr/lib/x86_64-linux-gnu/libopenconnect.so.5: version `OPENCONNECT_5_5' not found (required by openconnect)
    ```

    Found issue at below link
    https://github.com/dlenski/openconnect/issues/130

    Above issue solved using below command
    ```
    sudo apt autoremove
    ```
    Try connecting again
    This time, got push notification on mobile for approval

    But below error
    ```
    /usr/share/vpnc-scripts/vpnc-script: not found
    ```


    Followed below link to solve the vpnc-script issue
    https://www.infradead.org/openconnect/vpnc-script.html


    Next error
    ```
    Set up UDP failed; using SSL instead
    Connected as 10.5.201.132, using SSL, with ESP disabled
    /bin/sh: 1: /usr/share/vpnc-scripts/vpnc-script: Permission denied
    Script '/usr/share/vpnc-scripts/vpnc-script' returned error 126
    ```

    Seems the script has to be executable
    So make it executable using below command
    ```
    sudo chmod +x /usr/share/vpnc-scripts/vpnc-script
    ```

    Now try connecting again
    and
    Finally connected to VPN!

    ---

    HIH!
    _raevilman_



  6. raevilman created this gist Apr 25, 2019.
    1 change: 1 addition & 0 deletions setup.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    # Init