How to access a home server remotely: four ways to SSH in, ranked

To access a home server remotely, the simplest safe way is a mesh VPN such as Tailscale or WireGuard: nothing opens on your router, and you SSH to the server's private address from anywhere. Behind CGNAT or without a VPN app, a reverse SSH tunnel through a small VPS or a Cloudflare Tunnel does the job. Forwarding a port on your router comes last, because every scanner on the internet can then reach it.

Four ways to access a home server remotely, ranked

A Raspberry Pi, a NAS or an old laptop running services at home is easy to reach on your own Wi-Fi. From outside, something has to carry the connection in. Ranked from the one to try first to the last resort:

  1. Mesh VPN (Tailscale or WireGuard): your devices join one private network. Nothing opens on the router.
  2. Reverse SSH tunnel through a VPS: the home server connects out to a small server with a public address, and you go in through it.
  3. Cloudflare Tunnel: made for web apps on a public name; SSH works with an extra client.
  4. Router port forwarding: the oldest way. The port is open to the whole internet, and it fails behind CGNAT.

Before you choose, check whether you have a public address at all. If curl -4 https://ifconfig.me on the server differs from the WAN address on your router, or the WAN address starts with 100.64 to 100.127, your provider uses CGNAT and only the first three ways work. Our guide to SSH without a public IP explains the check.

How do you SSH into a home server with Tailscale?

Tailscale builds a WireGuard network between your devices, with an account and a hosted coordination service. On the home server:

curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale up
tailscale ip -4                     # the server's address, 100.x.y.z

Install the Tailscale app on your laptop and phone with the same account, then SSH as usual, to the 100.x address or to the machine's name:

ssh pi@100.101.102.103
ssh pi@homeserver                   # with MagicDNS on

Your normal SSH server and your keys keep working. Tailscale also has its own SSH mode, tailscale set --ssh, which signs you in with your Tailscale identity instead of keys. It answers only on port 22 of the Tailscale address.

Reach the rest of the home network

To SSH into a NAS or a router that cannot run Tailscale, make the server a subnet router:

echo 'net.ipv4.ip_forward = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf
sudo sysctl -p /etc/sysctl.d/99-tailscale.conf
sudo tailscale set --advertise-routes=192.168.1.0/24

Approve the route in the admin console. iPhone, iPad and Mac pick it up by themselves; Linux clients add --accept-routes. Or skip the routing and use the server as a jump host:

Host homeserver
    HostName 100.101.102.103
    User pi

Host nas
    HostName 192.168.1.20
    User admin
    ProxyJump homeserver

ssh nas now goes through the server in one step. Our guide to ProxyJump and jump hosts covers chains and scp through a jump.

What about plain WireGuard?

WireGuard on its own has no account and no third party, and you manage the keys. One peer needs an address the others can reach:

  • With a public IP at home, forward one UDP port, such as 51820, to the server. It is the only open port, and it belongs to WireGuard, not SSH.
  • Behind CGNAT, put the reachable peer on a VPS. The home server connects out to it with PersistentKeepalive = 25, the value WireGuard's quick start suggests for NAT.

Keys come from wg genkey and wg pubkey, and sudo wg-quick up wg0 starts the link. The no public IP guide has two tested config files.

How do you reach a home server behind CGNAT with a reverse SSH tunnel?

This needs only SSH and one server with a public address. The home server opens the connection, so the router and CGNAT never see an incoming one.

  1. On the home server, open the tunnel to the VPS:
    ssh -N -o ExitOnForwardFailure=yes -o ServerAliveInterval=30 \
        -R 2222:localhost:22 tunnel@vps.example.com
    Port 2222 on the VPS now leads to port 22 at home. It listens only on the VPS's loopback, so the internet cannot reach it.
  2. On your laptop, go through the VPS with ProxyJump:
    Host vps
        HostName vps.example.com
        User you
    
    Host home
        HostName localhost
        Port 2222
        User pi
        ProxyJump vps
        HostKeyAlias home
    HostKeyAlias keeps the home server's host key apart from whatever else answers on localhost.
  3. Connect with ssh home.

We ran this between two Debian 13 containers with OpenSSH 10.0, with only the VPS's port published, and ssh home from a Mac with OpenSSH 10.3 reached the home container.

The home server keeps a key that can log in to your VPS, so limit it. In the VPS's authorized_keys, this line allows that key the one remote port and no shell:

command="/bin/false",restrict,port-forwarding,permitlisten="localhost:2222" ssh-ed25519 AAAA... home-tunnel

A plain ssh -R ends when the connection drops. Run it under systemd or autossh so it comes back; see autossh and systemd and the full reverse SSH tunnel guide.

Can you SSH through a Cloudflare Tunnel?

Yes, with one more piece on the client. Cloudflare Tunnel runs cloudflared at home, which connects out to Cloudflare and publishes services on your domain.

  1. In the Cloudflare dashboard, open your tunnel, add a route of type Published application, choose a name such as ssh.example.com, and set the service to SSH at localhost:22.
  2. Protect it with a Cloudflare Access application, which Cloudflare recommends.
  3. On your laptop, install cloudflared and add to ~/.ssh/config:
    Host ssh.example.com
        ProxyCommand /usr/local/bin/cloudflared access ssh --hostname %h

A phone cannot run that ProxyCommand. For SSH from a phone, Cloudflare's other method uses the Cloudflare One Client on the device with Cloudflare Gateway, and keeps your own SSH keys. That is more setup than a mesh VPN, so Cloudflare Tunnel fits web apps, and Tailscale or WireGuard fits SSH.

Is port forwarding on your router safe for SSH?

It works, and it is the only way here that needs nothing but the router. What you accept:

  • Bots scan every public address. Your SSH port gets login attempts within minutes.
  • Most home connections change address, so you need dynamic DNS to find it.
  • Behind CGNAT there is nothing to forward from.

If you go this way, forward only SSH, never the web page of a NAS, a camera or the router. Then accept only keys, turn off root login and add fail2ban, as in our Linux server security checklist. Forwarding a high outside port, such as 52022, to port 22 inside cuts the noise in the logs; it does not replace the rest.

How do you access a home server remotely from your iPhone?

With the VPN on the phone, the home server is one more server in your SSH app. Wardterm, on iPhone, iPad, Android, Mac, Windows and Linux, takes care of the parts that are tedious to type:

  • Jump servers. Add the Pi or the VPS under Show more, Network and jumps, Jump servers. Add more for a chain, in order, or set them once on a group. The import of ~/.ssh/config brings in ProxyJump lines as chains. See jump hosts and proxies.
  • Saved tunnels. A local tunnel puts the web page of a home service on a port of your device, without publishing it. Start and stop it from the list. See port forwarding.
  • Mosh. On cellular, the session survives a switch from Wi-Fi to 4G and the phone's sleep. Over a mesh VPN, Mosh's UDP traffic reaches the server with no port to forward. See Mosh.
  • Keys in the secure chip. A Key on This Device is made inside the iPhone's or Mac's secure chip, cannot be copied, and can ask for Face ID or Touch ID at each sign-in. See keys on this device.

Once you are in, our guide to monitoring a server from iPhone shows what to check.

Questions

What is the safest way to access my home server remotely?

A mesh VPN such as Tailscale or WireGuard. Only your own devices can reach the server, nothing listens on your public address, and SSH keys still protect the login.

Can I access my home server without port forwarding?

Yes. A mesh VPN, a reverse SSH tunnel to a VPS and a Cloudflare Tunnel all start with an outgoing connection from home, so the router needs no open port. They work behind CGNAT too.

How do I know if I am behind CGNAT?

Compare the WAN address on your router's status page with what curl -4 https://ifconfig.me prints. If they differ, or the WAN address is between 100.64.0.0 and 100.127.255.255, your provider uses CGNAT and router port forwarding cannot work.

Should I use Tailscale or Cloudflare Tunnel for my homelab?

Many homelabs use both. Tailscale suits private access for you and your family, SSH included. Cloudflare Tunnel suits web apps that need a public address, with Cloudflare Access in front.

Is it safe to open port 22 on my router?

It works if the server accepts only keys, refuses root and runs fail2ban, but bots will try it within minutes. A mesh VPN avoids the exposure. If you forward a port, forward only SSH, never the admin page of a NAS or router.

How do I SSH into other devices on my home network, such as a NAS?

Make one machine a Tailscale subnet router with tailscale set --advertise-routes=192.168.1.0/24, or use it as a jump host with ProxyJump in your ssh config.

Do I need a static IP to reach my home server?

No. A mesh VPN and the tunnels find your server wherever it is. Only router port forwarding needs a stable address, which dynamic DNS gives you.

Can I SSH into my home server from an iPhone?

Yes. Install the Tailscale or WireGuard app on the iPhone, then connect with an SSH app. Wardterm adds jump servers, saved tunnels, Mosh and keys kept in the iPhone's secure chip.

Sources

Each page was read on the date shown. Prices and features change, so check the maker's page before you decide.

  1. Tailscale docs, subnet routers, read on
  2. Tailscale docs, Tailscale SSH, read on
  3. WireGuard, quick start, read on
  4. Cloudflare docs, SSH with client-side cloudflared, read on
  5. Cloudflare docs, connect to SSH servers, read on
  6. sshd(8), authorized_keys format, OpenBSD manual, read on
  7. Wardterm docs, jump hosts and proxies, read on

All posts