Ubuntu – How to create a VPN connection using only the terminal (SSH)

servervpn

I am trying to create a VPN connection for my Ubuntu Server machine to use. I only have access via ssh terminal session.

I have seen many articles detailing how to connect to an existing connection, but none about creating a new connection.

I am using Ubuntu Server 12.x

Best Answer

  • As I didn't understand what you need to do exactly, let me explain how VPN works:

    To have a VPN you need a VPN Server (where you connect to) and a VPN Client (the machine you use to connect to the Server). You can't create a connection without a VPN server. We have 3 possibilities here:

    • You want your server to connect to another one (a VPN Server). In this case you need a client and as there are different VPN types, you need to follow instructions from the VPN Server administrator.

    • You want to connect to your server from another machine (your local machine probably) and in this case you need to install a VPN server on your server and a client on your machine. For that I use OpenVPN since many years and it works very well with Windows and Ubuntu clients

    • You want to connect both machines to a hosted VPN server from a 3rd party and in this case as there are many different VPN types, you need to follow the instructions of the 3rd party administrator.

    If you only want a "private / encrypted" connection to your server, you already have SSH and you won't have much more with a VPN. A VPN is useful to connect to a network as if you were a local machine in the network and not so useful to connect to a single machine where you can use SSH connections for terminals (and redirect graphic output to your screen if the server has graphic desktop) and SSH tunnels to access other ports. For example tunneling with SSH a local port on your machine to port 3306 on the remote server to administer MySQL with a 100% encrypted connection instead of using phpmyadmin sending your DB root password over http.

    PPTP Update:

    For PPTP client via command line, you can use pptp-linux client:

    sudo apt-get install pptp-linux

    There are many tutorials on how to configure it:

    Edited after comments from OP: Ubuntu community help site worked.

    Others are available like PPTP Linux client. The tutorial is for command line client or GUI client so install only pptp-linux and not network-manager-pptp

    pptp-linux site instructions for Debian is also detailed for command line and should work without problem on Ubuntu.