I want to tunnel my OpenVPN traffic through an SSH tunnel. I have

  • An OpenVPN server behind a router running on port 4321
  • SSH server on the same machine on port 22
  • Router forwards ports to the server's IP to 1234->22 and 4321->4321

The server is configured this way:

dev tun
proto tcp
port 4321
ca /etc/openvpn/easy-rsa/pki/ca.crt
cert /etc/openvpn/easy-rsa/pki/issued/server_eqg0yy05M8ZkQjyy.crt
key /etc/openvpn/easy-rsa/pki/private/server_eqg0yy05M8ZkQjyy.key
dh /etc/openvpn/easy-rsa/pki/dh2048.pem
topology subnet
push "dhcp-option DNS"
push "dhcp-option DNS"
push "block-outside-dns"
push "redirect-gateway def1"
keepalive 10 120
remote-cert-tls client
tls-version-min 1.2
tls-auth /etc/openvpn/easy-rsa/pki/ta.key 0
cipher AES-256-CBC
auth SHA256
user nobody
group nogroup
crl-verify /etc/openvpn/crl.pem
status /var/log/openvpn-status.log 20
status-version 3
verb 3

And my client side looks like this:

dev tun
proto tcp-client
remote localhost 4321
route [my public IP] net_gateway
resolv-retry infinite
key-direction 1
remote-cert-tls server
tls-version-min 1.2
verify-x509-name server_eqg0yy05M8ZkQjyy name
cipher AES-256-CBC
auth SHA256
verb 3

If I use these server and client conf files on my Ubuntu laptop, and execute

ssh user@[my public IP] -p 1234 -L 4321:localhost:4321


sudo openvpn --config client1.ovpn

it works!

But on Android I can't get it working. I use ConnectBot (which was advised by many people), on which I am able to setup a connection to my SSH server and I have a local port forward 4321 -> localhost:4321.

When I have the SSH with active port forwarding running, I try to connect my OpenVPN with the official app (actually both official apps and two Androipd phones), ConnectBot says "Connection lost", breaking my tunnel. Why does the connection cut with the same configuration with "route [my public IP] net_gateway" that works on my PC?


I did not have experience of openvpn through ssh tunnels. but I used a lot of openvpn clients app and most of them are having problems with my openvpn setup. you might try with the one i'm currently using and is working fine: OpenVPN for Android

  • Hi, this is actually one of the two apps I tried. The other one is OpenVPN Connect. They both work without the tunnel, but they seem to breakthe SSH tunnel if it's used. People have used it successfully for this purpose according to internet. – Anton Apr 18 '18 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.