Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    is there a way to download .ovpn file from terminal?

    OpenVPN
    1
    1
    318
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      mercy_angel
      last edited by

      Is there a way to download .ovpn file or whole bundle (OpenVPN/Client Export Utility) from some ubuntu terminal?

      i found this here link

      but problem here is that download is only for .key and .crt file.
      Have anyone idea how to download ovpn file, cause i need to download whole bundle.

       BACKUPDIR="where the cert will go"
      USERNAME="pfsense user"
      PASSWORD="pfsense password"
      PORT="pfsense port"
      SITE="pfsense ip or address"
      
      wget -qO- --keep-session-cookies --save-cookies /tmp/pfsense_cookies.txt \
        --no-check-certificate https://$SITE/system_certmanager.php \
        | grep "name='__csrf_magic'" | sed 's/.*value="\(.*\)".*/\1/' > /tmp/pfsense_csrf.txt
      
      
      wget -qO- --keep-session-cookies --load-cookies /tmp/pfsense_cookies.txt \
        --save-cookies /tmp/pfsense_cookies.txt --no-check-certificate \
        --post-data "login=Login&usernamefld="$USERNAME"&passwordfld="$PASSWORD"&__csrf_magic=$(cat /tmp/pfsense_csrf.txt)" \
        https://$SITE/system_certmanager.php  | grep "name='__csrf_magic'" \
        | sed 's/.*value="\(.*\)".*/\1/' > /tmp/pfsense_csrf2.txt
      
              if [ -e /tmp/pfsense_cookies.txt ]; then
              FILENAME="$BACKUPDIR/certname.crt"
      
      wget --keep-session-cookies --load-cookies /tmp/pfsense_cookies.txt --no-check-certificate \
        --post-data "act=exp&id=1&__csrf_magic=$(head -n 1 /tmp/pfsense_csrf2.txt)" \
        https://$SITE/system_certmanager.php -O $FILENAME
      
              FILENAME2="$BACKUPDIR/certname.key"
      
      wget --keep-session-cookies --load-cookies /tmp/pfsense_cookies.txt --no-check-certificate \
        --post-data "act=key&id=1&__csrf_magic=$(head -n 1 /tmp/pfsense_csrf2.txt)" \
        https://$SITE/system_certmanager.php -O $FILENAME2
      
      #rm -f /tmp/pfsense_cookies.txt
      #rm -f /tmp/pfsense_csrf.txt
      #rm -f /tmp/pfsense_csrf2.txt
      
              else
                      echo "Failed to retrieve cert from $SITE"
              fi
      
      done
      
      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.