
{"id":1670,"date":"2025-05-18T13:38:26","date_gmt":"2025-05-18T13:38:26","guid":{"rendered":"https:\/\/help.getfoxyproxy.org\/?post_type=ht_kb&#038;p=1670"},"modified":"2025-05-18T16:07:08","modified_gmt":"2025-05-18T16:07:08","slug":"manual-setup-for-ubuntu-bulk-import","status":"publish","type":"ht_kb","link":"https:\/\/help.getfoxyproxy.com\/index.php\/knowledge-base\/manual-setup-for-ubuntu-bulk-import\/","title":{"rendered":"Manual Setup for Ubuntu (Many Servers &#8211; Bulk Import)"},"content":{"rendered":"\n<p>If you have many OpenVPN config files, <a href=\"https:\/\/help.getfoxyproxy.org\/index.php\/knowledge-base\/manual-setup-for-ubuntu-openvpn\/\">adding them once at a time<\/a> is tedious. Here&#8217;s how to add them all at once with a bash script.<\/p>\n\n\n\n<p><strong>Step 1: Download OpenVPN Configuration files from FoxyProxy<\/strong><\/p>\n\n\n\n<p>If you don\u2019t already have OpenVPN config files for your FoxyProxys servers, download them from the&nbsp;<a href=\"https:\/\/getfoxyproxy.org\/panel\/\">FoxyProxy Control Panel<\/a>. Login and select \u201c<strong>Click here to download all Tunneblick\/OpenVPN files as zip<\/strong>.\u201d If you have any trouble downloading the files, contact&nbsp;<a href=\"https:\/\/getfoxyproxy.org\/contact\/\">FoxyProxy Support<\/a>&nbsp;and we\u2019ll be glad to email it to you.<\/p>\n\n\n\n<p>Unzip the files. They files are used in Step 4.<\/p>\n\n\n\n<p><strong>Step 2: Create script<\/strong><\/p>\n\n\n\n<p>Open Ubuntu&#8217;s<strong> <\/strong>Text Editor and paste this<strong> <\/strong>script:<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n\n# import-openvpn.sh\n# Usage: .\/import-openvpn.sh &#91;--delete-vpn] &lt;directory-for-ovpn-files&gt;\n#   Note: --delete-vpn deletes all VPN connections, not just FoxyProxy OpenVPN ones\n\n# Check for --delete-vpn flag\ndelete_vpn=false\nif &#91;&#91; \"$1\" == \"--delete-vpn\" ]]; then\n    delete_vpn=true\n    shift  # Shift arguments so that the rest are treated as .ovpn file paths\nfi\n\n# Check if directory is provided\nif &#91; -z \"$1\" ]; then\n    echo \"Usage: $0 &#91;--delete-vpn] &lt;directory-for-ovpn-files&gt;\"\n    echo \"Note: --delete-vpn deletes all VPN connections, not just OpenVPN ones\"\n    exit 1\nfi\n\ndirectory=$1\n# Verify the directory exists\nif &#91; ! -d \"$directory\" ]; then\n    echo \"The specified directory does not exist.\"\n    exit 1\nfi\n\n# Check if there are any .ovpn files in the specified directory\nshopt -s nullglob  # Enable nullglob to avoid the pattern expanding to itself if no files match\novpn_files=(\"$directory\"\/*.ovpn)\n\nif &#91; ${#ovpn_files&#91;@]} -eq 0 ]; then\n    echo \"No .ovpn files found in the directory.\"\n    exit 1\nfi\nshopt -u nullglob  # Disable nullglob after checking\n\n# Credentials prompts\nread -p \"Enter FoxyProxy username: \" username\n# Prompt user for password twice\nread -p \"Enter FoxyProxy password: \" -s password1\necho\nread -p \"Confirm password: \" -s password2\necho\n\n# Strip any leading\/trailing whitespace or newlines\npassword1=$(echo -n \"$password1\")\npassword2=$(echo -n \"$password2\")\n\n# Compare the passwords\nif &#91; \"$password1\" != \"$password2\" ]; then\n    echo \"Passwords do not match\"\n    exit 1\nfi\n\n# If delete_vpn is true, delete all existing VPN connections\nif &#91; \"$delete_vpn\" = true ]; then\n    echo \"Deleting all existing VPN connections...\"\n    # Retrieve all VPN connection UUIDs\n    vpn_uuids=$(nmcli -g UUID,TYPE connection show | grep vpn | cut -d: -f1)\n    \n    # Delete each VPN connection by UUID\n    for uuid in $vpn_uuids; do\n        echo \"Deleting VPN connection with UUID: $uuid\"\n        sudo nmcli connection delete uuid \"$uuid\"\n    done\nfi\n\n# Initialize counter to track number of ovpn files processed\nupdated_count=0\n\n# Process .ovpn files\nfor path in \"$directory\"\/*.ovpn\ndo\n    name=$(basename \"$path\" \".ovpn\")\n    \n    # Check if the connection with the same name already exists\n    existing_connection=$(nmcli connection show \"$name\" 2&gt;\/dev\/null)\n\n    # If connection exists, delete it before importing the new one\n    if &#91; -n \"$existing_connection\" ]; then\n        echo \"Connection '$name' already exists. Deleting the old connection before importing new.\"\n        sudo nmcli connection delete \"$name\"\n    fi\n\n    # Import the new VPN connection setting\n    echo \"Importing OpenVPN connection: '$name'\"\n    sudo nmcli --terse connection import type openvpn file \"$path\" &gt; \/dev\/null\n\n    # Modify the connection with username and password\n    sudo nmcli connection modify \"$name\" vpn.persistent true\n    sudo nmcli connection modify \"$name\" vpn.user-name \"$username\"\n    sudo nmcli connection modify \"$name\" +vpn.data \"password-flags = 0, username = $username\"\n    sudo nmcli connection modify \"$name\" +vpn.secrets \"password=$password1\"\n    \n    # Increment the counter\n    updated_count=$((updated_count + 1))\ndone\n\necho \"$updated_count OpenVPN connection settings have been successfully imported.\"\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p><strong>Step 3: Save the script<\/strong> <strong>and give it executable permission<\/strong><\/p>\n\n\n\n<p>Save the Text Editor as a file with the name <strong>import-ovpn.sh<\/strong> anywhere you have write access, but preferably in the same directory where the .ovpn files from<strong> Step 1 <\/strong>are also saved. Then give<strong> import-ovpn.sh<\/strong> executable permission. Right-click on the file in Nautilus (Ubuntu&#8217;s file manager), select <strong>Properties<\/strong>, and enable <strong>Executable as Program<\/strong>:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"474\" height=\"670\" src=\"https:\/\/help.getfoxyproxy.org\/wp-content\/uploads\/2025\/05\/image-17.png\" alt=\"\" class=\"wp-image-1683\" srcset=\"https:\/\/help.getfoxyproxy.org\/wp-content\/uploads\/2025\/05\/image-17.png 474w, https:\/\/help.getfoxyproxy.org\/wp-content\/uploads\/2025\/05\/image-17-212x300.png 212w, https:\/\/help.getfoxyproxy.org\/wp-content\/uploads\/2025\/05\/image-17-35x50.png 35w\" sizes=\"(max-width: 474px) 100vw, 474px\" \/><\/figure>\n\n\n\n<p><strong>Step 4: Run the script<\/strong><\/p>\n\n\n\n<p>Open a terminal and run the script. You will be prompted for a sudo password since the script requires sudo access to execute nmli. Arguments and options for the script are:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ .\/import-openvpn.sh \nUsage: .\/import-openvpn.sh &#91;--delete-vpn] &lt;directory-for-ovpn-files&gt;\n<span class=\"has-inline-color has-vivid-red-color\">Note: --delete-vpn deletes all VPN connections, not just FoxyProxy OpenVPN ones<\/span>\n<\/code><\/pre>\n\n\n\n<p>Here is sample execution and output. <strong>Note the period at end of line indicating the .ovpn files are in the current directory<\/strong>.  <span class=\"has-inline-color has-vivid-red-color\">The &#8211;delete-vpn flag deletes all VPN connections, not just FoxyProxy OpenVPN connections!<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ .\/import-ovpn.sh --delete-vpn .\nEnter FoxyProxy username: aceventura\nEnter FoxyProxy password: \nConfirm password: \nDeleting all existing VPN connections...\nDeleting VPN connection with UUID: d920dee5-f93b-46ea-bafe-352cfa15e570\n&#91;sudo] password for martinfowler: \nConnection 'Monagolia-Ulaanbaatar' (d920dee5-f93b-46ea-bafe-352cfa15e570) successfully deleted.\nImporting OpenVPN connection: 'Uganda-Kampala-2'\nImporting OpenVPN connection: 'VietNam-Hanoi-35'\nImporting OpenVPN connection: 'Myanmar-Naypyidaw-4'\nImporting OpenVPN connection: 'Tehran-Iran-6'\n...\n...\n1612 OpenVPN connection settings have been successfully imported.\n<\/code><\/pre>\n\n\n\n<p><strong>Step 5: Connect \/ Disconnect<\/strong><\/p>\n\n\n\n<p>Open <strong>Settings -> Network<\/strong>. There are several ways to do this. Here is one. Click the network icon in the taskbar, then the gear icon. See the green arrows in this screenshot. Network settings can also be opened from the desktop <strong>Show Apps<\/strong> icon and then searching for <strong>Settings<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/help.getfoxyproxy.org\/wp-content\/uploads\/2025\/05\/image-7.png\" alt=\"This image has an empty alt attribute; its file name is image-7.png\"\/><\/figure>\n\n\n\n<p>Connect or disconnect with these screens If you have many servers, not all of them may appear in the taskbar list. However, the Network Settings screen shows all VPN servers.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/help.getfoxyproxy.org\/wp-content\/uploads\/2025\/05\/image-11.png\" alt=\"This image has an empty alt attribute; its file name is image-11.png\"\/><\/figure>\n\n\n\n<p>Network Settings (complete list):<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/help.getfoxyproxy.org\/wp-content\/uploads\/2025\/05\/image-10.png\" alt=\"This image has an empty alt attribute; its file name is image-10.png\"\/><\/figure>\n\n\n\n<p>If the connection succeeds, look for the VPN icon in the task bar. You can click it to see which VPN connection is active:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/help.getfoxyproxy.org\/wp-content\/uploads\/2025\/05\/image-16.png\" alt=\"This image has an empty alt attribute; its file name is image-16.png\"\/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>If you have many OpenVPN config files, adding them once at a time is tedious. Here&#8217;s how to add them all at once with a bash script. Step 1: Download OpenVPN Configuration files from FoxyProxy If you don\u2019t already have OpenVPN config files for your FoxyProxys servers, download them from the&nbsp;FoxyProxy Control Panel. Login and [&hellip;]<\/p>\n","protected":false},"author":4,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":[],"ht-kb-category":[75],"ht-kb-tag":[],"_links":{"self":[{"href":"https:\/\/help.getfoxyproxy.com\/index.php\/wp-json\/wp\/v2\/ht-kb\/1670"}],"collection":[{"href":"https:\/\/help.getfoxyproxy.com\/index.php\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/help.getfoxyproxy.com\/index.php\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/help.getfoxyproxy.com\/index.php\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/help.getfoxyproxy.com\/index.php\/wp-json\/wp\/v2\/comments?post=1670"}],"version-history":[{"count":26,"href":"https:\/\/help.getfoxyproxy.com\/index.php\/wp-json\/wp\/v2\/ht-kb\/1670\/revisions"}],"predecessor-version":[{"id":1747,"href":"https:\/\/help.getfoxyproxy.com\/index.php\/wp-json\/wp\/v2\/ht-kb\/1670\/revisions\/1747"}],"wp:attachment":[{"href":"https:\/\/help.getfoxyproxy.com\/index.php\/wp-json\/wp\/v2\/media?parent=1670"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/help.getfoxyproxy.com\/index.php\/wp-json\/wp\/v2\/ht-kb-category?post=1670"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/help.getfoxyproxy.com\/index.php\/wp-json\/wp\/v2\/ht-kb-tag?post=1670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}