0

I have a remote Linux server with no GUI which I connect to using SSH or putty. I want to install OpenVPN CLI on it so that programs have secure access to internet.

I succeeded in configuring the VPN in the remote server; however, I got locked out and I could not connect to it anymore.

What are my options to have VPN running on this machine, and I still be able to SSH to it?

note: I only have 3 java programs running on this machine that access internet, and it would be enough for me if only these 3 programs connect to internet via VPN and the rest of incoming/outgoing connections are non-VPN.

3
  • Start OpenVPN in separate network namespace (see e.g. here), move the 3 Java programs into that namespace.
    – dirkt
    Sep 8, 2017 at 16:22
  • Thanks for the pointer to namespace. Still I could not get it to work though :( Am I correct to assume that I was locked out of my server because of VPN connections? Sep 9, 2017 at 18:37
  • You were locked out because OpenVPN by default (unless you disable it) sets a default route, which causes ssh packets to go out on this route. But the other end of the VPN is likely behind NAT, so the whole ssh connection breaks down, and you can't get in through the NAT.
    – dirkt
    Sep 9, 2017 at 20:33

1 Answer 1

0

I found out that one easy way around this problem is to add my own IP in the routing exception.(original post here).

Basically just run following code on your machine that you want to run VPN client.

 route add -host X.X.X.X gw Y.Y.Y.Y

X.X.X.X is the PUBLIC IP address of your current computer that you use to SSH to the your server. Just google whatismyip to see your current public ip.

Y.Y.Y.Y is the gateway address on your server before you start VPN client. you can run this route command, or command below to get your default gateway:

ip route | grep default

Note: I reckon that if I SSH to my server from home over a common ISP connection, my public IP might change randomly, and eventually I am going to lose access to my server again. If you have any idea please let me know.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .