I have two VPNs setup on my Ubuntu machine, one using vpnc and one using PPTP. These were both setup using the GNOME network manager interface and work great. However on occasion I need to access this machine remotely - is there a way to connect or disconnect to these VPNs from the command line?
If you want to interact with NetworkManager from the command line you can use the "nmcli" command.
list all NM connections:
start connection (wifi, vpn, etc):
(more nmcli commands in the nmcli manpage).
Also note that regular users usually don't have permission to control networking. Using the commands above with
If that happens to you, it's likely that the VPN password is stored in your user's gnome-keyring, which makes it inaccessible to the root user. This comment explains why.
To fix this, edit /etc/NetworkManager/system-connections/ConnectionName and under
And add the following:
Then starting the VPN connection with
ihashacks's answer with Matt's comments worked for me... almost. Had to tweak one line.
my password-flag line actually read: "Xauth password-flag". The accepted answer wouldn't work for me until I changed to the following
Not sure why my vpn connections have "Xauth" before every mention of password.
(Sorry this is a new answer, can't yet make comments.)
protected by Community♦ May 31 '12 at 18:58
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?