A tunnel forwards a port through one of your saved hosts. MorphGate keeps tunnels in the vault, so they sync with it, and you start and stop them on the Tunnels page.
Three kinds of tunnel
- Local
- A port on this computer reaches a destination the server can see, like
ssh -L. Typical use: a database that only listens behind the server. - Remote
- A port on the server reaches a destination this computer can see, like
ssh -R. Typical use: showing a local development server to the server. - SOCKS proxy
- A SOCKS5 proxy on this computer. Every connection through it leaves from the server, like
ssh -D. Point a browser at it. Names are looked up on the server's side.
Create a tunnel
- Choose Tunnels in the sidebar, then New tunnel. You need at least one saved host.
- Give it a Name, or leave it empty for one made from the host and destination.
- Pick the host under Through host.
- Pick Local, Remote or SOCKS proxy.
- Under Listen on, enter the address and port to listen on: on this computer for local and SOCKS tunnels, on the server for remote ones. For a remote tunnel, port 0 lets the server pick one.
- For local and remote tunnels, enter the Destination and its port. For a local tunnel, the destination is as seen from the server; for a remote one, as seen from this computer.
- Choose Save, or Save & start.
Listening on 127.0.0.1 (the default) keeps a local or SOCKS tunnel to this computer. If you enter another address, MorphGate warns that other machines on your network can use the tunnel. The SOCKS proxy has no password, so on such an address anyone who can reach the port can use your server as a proxy.
For a remote tunnel, the server decides who can reach the port. OpenSSH servers keep it to the server itself unless their GatewayPorts setting allows more.
Start and stop
The Tunnels page lists every tunnel with a switch, what it forwards, the host it goes through and whether that host is connected, and its state, such as Running · 2 open. Turn the switch on to start the tunnel, off to stop it. The Running filter shows only the tunnels that run. A group's page has the same switches for the tunnels through its hosts. In the sidebar, Tunnels shows how many are running (for example 2 on).
- Each row shows where the tunnel listens and where it leads, for example
L :15432 → db:5432, and while it runs, how many connections are open through it. - A tunnel uses its host's whole route: the host's saved sign-in, its jump hosts and its VPN. If the host has no saved password, MorphGate asks for one, for this connection only.
- Saving changes to a running tunnel stops it.
- If a tunnel's connection drops, its switch turns off: within seconds when the server closes it, within about a minute and a half when the network just goes silent. The tunnel doesn't start again by itself: turn it back on.
In the phone layout, the tunnels are listed with their switches under More.
When a tunnel won't start
- could not listen on and an address: another program already uses that port on this computer, or the system doesn't allow it. Pick another port.
- The same message ending in on the server: the server refused to listen for a remote tunnel, for example because the port is taken there or forwarding is turned off.
- Any other message is the same one a terminal to that host would show. See Hosts, groups and identities and Jump hosts.
Once a tunnel runs, a single connection through it can still fail, for example when the destination is down or the server doesn't allow forwarding to it. That connection is closed, and the tunnel keeps running.
Good to know
- A tunnel and its host must be in the same vault. In a team's shared vault, everyone who can open the vault can start its tunnels, view-only members too. Changing them needs edit access.
- Each tunnel has its own connection to the host, separate from your terminal tabs.
- Every tunnel is saved in the vault. To forward a port for a host you reached with Quick connect, save the host first.
- Locking the vault stops every tunnel, and so does quitting MorphGate.
- Tunnels don't start by themselves when MorphGate opens. Start the ones you need.
- The SOCKS proxy speaks SOCKS5 and supports plain connections only: no username and password, no UDP.