SSH VPN
An SSH VPN profile turns an ordinary OpenSSH server into a VPN: every TCP connection of the phone travels through one SSH session to the server, which makes it to the destination. Nothing but OpenSSH has to run on the server; an optional relay on the server carries UDP as well. SRP VPN Connect does this with the same core on iPhone and Android: libssh2 1.11.1 for SSH and the packet engine of hev-socks5-tunnel.
How an SSH VPN connection works
- SSH. The app opens an SSH connection to the server, on port 22 unless the profile names another, checks the server's host key when the profile has one, and logs in with the profile's password.
- A check. Before it calls itself connected, the app makes sure the server lets the user forward TCP connections, and, with UDP Relay on, that the relay answers.
- The tunnel. All of the phone's IPv4 traffic goes into the app. Each TCP connection becomes an SSH channel to its destination, which the server opens. Names are answered by the app itself with placeholder addresses, so the server looks up the real address: DNS works with or without the relay.
- UDP. With UDP Relay on, UDP goes through the SSH session to the relay on the server, which sends it on. Without the relay, UDP does not get through.
- Keeping it up. The app sends a keepalive every 15 seconds and answers the server's own. When the connection breaks, or the server has not answered for 50 seconds, Auto Reconnect opens a new SSH session; connections that were open start again, as SSH cannot carry a session over to a new one.
Where to start
- Set up the server: OpenSSH server adds a user that may only forward TCP and installs the UDP relay.
- Install the app: on iPhone from TestFlight, on Android by building it from the source; see Installation. Our tests ran the code of commit
8b4eb1afon both phones, and the lifecycle cases that of3c4e4def, which follows it; on iPhone use TestFlight build 39 (commitc088fdb7) or later, the first with this code. - Add an SSH VPN profile: Setting up the app.
- The server settings that matter to the app, and what each profile field does: Configuration Reference.
- If it does not connect: Troubleshooting.
What was tested
Test results lists every case we ran against our OpenSSH server, with its result on an iPhone and on an Android phone: transfers in both directions and 16 connections at once, UDP through the relay and without it, password and keyboard-interactive logins and their refusals, a user the server does not let forward TCP, the host key check with each of the server's key types, other ports, a port that does not answer and wrong server names, a hardened set of algorithms and each cipher alone, a login banner, the server's keepalives on an idle VPN, the log levels, the server set up exactly as OpenSSH server describes, and what happens on sleep, when the server ends the session or resets the connection, when the network path goes dead, when the phone switches networks, when the server is away for a while and when Retry Times runs out.