You get locked out of your VPS because once the VPN service is up, your ssh packets get routed via the VPN not your VPS's public IP 50.2.1.3.
Lets assume your server's:
- Public IP is 50.1.2.3 (as per your example setup)
- Public IP Subnet is 50.1.2.0/24
- Default Gateway is probably 50.1.2.1
- eth0 is device to gateway
Do the following using iproute2:
ip rule add table 128 from 50.1.2.3 ip route add table 128 to 50.1.2.0/24 dev eth0 ip route add table 128 default via 50.1.2.1 Then run your OpenVPN client config: openvpn --config youropenvpn-configfile.ovpn &
You will then be able to ssh into your server while your server is connected to the vpn service.
You would need to add the appropriate iptable filters to restrict access to your public IP from non-ssh:22 sessions.
To understand these commands in details, see the related answers.