Setting up Open VPN client on Amazon EC2
In my case, executing the following successfully started the openvpn connection without losing ssh functionality:
Example
sudo route add -host 96.113.49.112 gw 10.0.0.1
openvpn --config newvpnconfigfile1.ovpn
where the ip following host
is our office network's public IP (you can get this by just typing "what's my ip" into Google on your own pc) and the ip following gw
is the ec2 instance's gateway IP (seen on the first line, second column of the output of netstat -anr
when you execute it on your AWS server).
Checking the reported public ip before and after executing the above showed that it had changed from reporting as our normal IP address to reporting as the IP address of the VPN server.
Some more background information can be found here: Prevent SSH connection lost after logging into VPN on server machine
In my case I only needed to route a certain IP through the VPN connection, so I added those lines to the OpenVPN's configuration file:
route-nopull
route The.IP.To.Go 255.255.255.255
And then:
sudo openvpn --config vpnconfigfile.ovpn
Taken from https://serverfault.com/a/747828 and https://superuser.com/a/628488