VNC over SSH on iPhone, iPad and Mac
Direct VNC is not encrypted, and VeNCrypt/TLS is not supported. Run
VNC through an SSH tunnel instead. AnyPane does what
ssh -L 5901:127.0.0.1:5901 user@server plus a VNC viewer
would do, in one connection.
Why tunnel VNC through SSH
Classic VNC sends the screen, your keystrokes and the clipboard without encryption, and standard VNC authentication only uses the first eight characters of the password. Through SSH, everything between your device and the server is encrypted, the server is identified by its host key, and the VNC port never has to be open to the network.
You need three things on the remote side:
- an SSH server that allows TCP forwarding,
- a VNC server on the same machine, or on one it can reach,
- an account you are authorized to use on both.
Prepare the server
Linux
Make the VNC server listen on loopback only, so the tunnel is the only way in. For example:
-
TigerVNC: set
localhostin its config, or start the server with-localhost yes. -
x11vnc, to share the desktop that is already on screen:
x11vnc -localhost -display :0 -usepw.
VNC ports follow display numbers: display :0 is port
5900, :1 is 5901,
:2 is 5902, and so on.
macOS
Turn on Screen Sharing and Remote Login in System Settings → General →
Sharing. Screen Sharing listens on port 5900, and you sign
in with a macOS account name and password. See
Control your Mac from iPhone or iPad
for the full walkthrough.
Set it up
- Add an SSH connection to the server with its address, port, username and a credential (password or OpenSSH Ed25519 key). Connect once and verify the SHA-256 host key fingerprint.
-
Add a VNC connection. Address:
127.0.0.1if the VNC server runs on that SSH host. Port: the VNC port, such as5900for macOS Screen Sharing and display:0, or5901for display:1. - Under Authentication, enter the VNC password. Apple Screen Sharing and MS-Logon also need a username.
- Under Security, set SSH Tunnel to the SSH connection from step 1. The default, None (unencrypted), is direct VNC.
- Add the VNC connection to a workspace and open it. Add the SSH connection to the same workspace if you want a shell next to the desktop.
The tunnel doesn’t need an open terminal pane. On iPad and Mac, put the shell and the desktop side by side; on iPhone, switch between them with tabs.
How the tunnel works
When the VNC session starts, AnyPane opens the SSH connection and a
temporary forward that listens on loopback only, then points the
viewer at it. It is the same path as ssh -L, without a
port you have to pick or remember.
The VNC address is resolved on the SSH host, not on your device:
127.0.0.1 means the SSH host itself. To reach a VNC server
on another machine behind the SSH host, enter that machine’s address
as the SSH host sees it. The hop from the SSH host to that machine
isn’t covered by the tunnel.
If the SSH connection you pick uses a jump host, the VNC session goes through both hops.
Troubleshooting
- SSH connects, but the VNC pane doesn’t
-
Confirm the VNC server is listening on the host:
ss -ltn | grep 590on Linux,lsof -nP -iTCP -sTCP:LISTEN | grep 590on macOS. If it only listens on127.0.0.1, the VNC address must be127.0.0.1. - The tunnel is refused
-
sshd must allow
AllowTcpForwarding, and noDisableForwardingorPermitOpenrule may block the VNC port. Check the effective settings withsudo sshd -T | grep -iE 'forwarding|permitopen'. - VNC authentication failed
- VNC auth is separate from SSH auth. Check the VNC password, and the username for Apple Screen Sharing or MS-Logon.
- The desktop feels slow
- Lower the image quality in the VNC settings, and use Fit scaling on small screens. Large or high-resolution desktops send more data.
- The session drops when you leave the app
- iOS and iPadOS may suspend connections in the background. Return to AnyPane and connect again.
Limits
Keep the VNC port off the public internet; the SSH tunnel is your encryption. No RDP, no remote audio, no session recording.
FAQ
- Is VNC over SSH secure?
- It is as strong as your SSH setup. Prefer Ed25519 keys to passwords, verify the host key, and keep the VNC server bound to loopback so it can only be reached through SSH.
- Which port do I enter?
-
The VNC server’s port on the SSH host:
5900plus the display number. macOS Screen Sharing uses5900. - Do I need a terminal open for the tunnel?
- No. The tunnel belongs to the VNC session.
- Does it work with a Windows PC?
- Yes, if the PC runs a VNC server and an SSH server (Windows includes OpenSSH Server as an optional feature). RDP isn’t supported.
Related
- Control your Mac from iPhone or iPad
- Reach a server through one SSH jump host
- SSH local port forwarding
- Troubleshooting and limits
Get AnyPane
For iPhone, iPad and Mac.