How to view my custom VPN service listed in a terminal in order to export it? When I execute this command to list my network services:
networksetup -listallnetworkservices

I only get Wifi, why my VPN configuration is not listed here (it's in the Network Preferences list) ? And how can I get it listed in the terminal ?
My goal is to export it via a terminal, edit the configuration manually in a text editor and re-import it.
EDIT
I have set &quot;MyVPN&quot; like below and it's connecting via this Network Configuration window.

But when trying to list it or run it with:
networksetup -connectpppoeservice &quot;MyVPN&quot;

Or with:
scutil --nc start &quot;MyVPN&quot;
No service

Then it doesn't work.
Use networksetup or scutil
You can use it to at least establish/ disconnect connections to the VPN.
Use this command to connect the VPN configured with the name &quot;myVPN&quot;:
networksetup -connectpppoeservice &quot;myVPN&quot;

Disconnect from the VPN
networksetup -disconnectpppoeservice &quot;myVPN&quot;

When you want to check the connection status
networksetup -showpppoestatus &quot;myVPN&quot;


The &quot;system configuration utility&quot; or scutil command provides access to network configuration, too.
To connect to your VPN use this command:
scutil --nc start &quot;myVPN&quot;

Run the following command to disconnect from the VPN:
scutil --nc stop &quot;myVPN&quot;

If you want to check the connection status, use:
 scutil --nc status &quot;myVPN&quot;

Let's make it even better
Github Code
#!/bin/bash
#
# Provides some basic utilities for VPN connections.

readonly cmd=&quot;${1}&quot;
readonly vpn=&quot;${2}&quot;


err() {
  echo &quot;$*&quot; &gt;&amp;2
}

validateCmd() {
  if [[ -z &quot;${cmd}&quot; ]]; then 
    err &quot;Command must be provided: [connect, disconnect, status, list]&quot;
    exit 1
  fi
}

validateVpnName() {
  if [[ -z &quot;${vpn}&quot; ]]; then 
    err &quot;VPN name must be provided as second argument&quot;
    exit 1
  fi
}

isConnected() {
  networksetup -showpppoestatus &quot;${vpn}&quot; | grep -qv &quot;^connected$&quot;
}

enterPassword() {
  sleep 1
  osascript -e &quot;tell application \&quot;System Events\&quot; to keystroke \&quot;${1}\&quot;&quot;
  osascript -e &quot;tell application \&quot;System Events\&quot; to keystroke return&quot;
}

connect() {
  if ! isConnected; then
    err &quot;Already connected to '${vpn}'&quot;
    exit 1
  fi

  local readonly password=&quot;$(security find-generic-password -s &quot;${vpn}&quot; -w)&quot;
  if [[ -z &quot;${password}&quot; ]]; then
    err &quot;Unable to find VPN password in keychain&quot;
    exit 1
  fi

  scutil --nc start &quot;${vpn}&quot;
  enterPassword &quot;${password}&quot;
}

disconnect() {
  scutil --nc stop &quot;${vpn}&quot;
}

status() {
  scutil --nc status &quot;${vpn}&quot;
}

list() {
  scutil --nc list
}

main() {
  validateCmd

  case &quot;${cmd}&quot; in
    connect)
      validateVpnName
      connect &quot;${vpn}&quot;
      ;;
    disconnect)
      validateVpnName
      disconnect &quot;${vpn}&quot;
      ;;
    status)
      validateVpnName
      status &quot;${vpn}&quot;
      ;;
    list)
      list
      ;;
    *)
      err &quot;Unexpected cmd '${cmd}', must be one of [connect, disconnect, status, list]&quot;
      exit 1
      ;;
  esac
}

set -e 
main &quot;${@}&quot;
set +e

Open the script in an editor and add this code. Let's say it's called vpnConnection.
Add #!/bin/bash so that it can start without further ado
echo `'#!/bin/bash'` &gt; ~/vpnConnection.sh &amp;&amp; chmod +x ~/vpnConnection.sh

./vpnConnection.sh list show all VPN connections
./vpnConnection.sh connect &quot;myVPN&quot; Connect to the VPN &quot;myVPN&quot; and automatically enter the password
./vpnConnection.sh disconnect &quot;myVPN&quot; disconnect the VPN &quot;myVPN&quot;
./vpnConnection.sh status &quot;myVPN&quot; view the connection status for VPN &quot;myVPN&quot;