|
| 1 | +--- |
| 2 | +title: How to SSH into a Raspberry Pi from iPhone or iPad |
| 3 | +--- |
| 4 | + |
| 5 | +# How to SSH into a Raspberry Pi from iPhone or iPad |
| 6 | + |
| 7 | +The Raspberry Pi is a staple of home labs, automation projects, and self-hosted services. WebSSH turns your iPhone or iPad into a capable terminal — so you can check logs, restart services, or run commands on your Pi without needing a laptop nearby. |
| 8 | + |
| 9 | +This guide covers everything from enabling SSH on the Pi to connecting securely from iOS with a private key. |
| 10 | + |
| 11 | +## Prerequisites |
| 12 | + |
| 13 | +### Enable SSH on Your Raspberry Pi |
| 14 | + |
| 15 | +SSH is disabled by default on recent Raspberry Pi OS images. Enable it before trying to connect. |
| 16 | + |
| 17 | +**If you have physical access to the Pi:** |
| 18 | + |
| 19 | +1. Open a terminal on the Pi (or connect a keyboard and monitor) |
| 20 | +2. Run `sudo raspi-config` |
| 21 | +3. Navigate to **Interface Options → SSH → Enable** |
| 22 | +4. Reboot: `sudo reboot` |
| 23 | + |
| 24 | +**Headless setup (no monitor needed):** |
| 25 | + |
| 26 | +Before first boot, place an empty file named `ssh` (no extension) in the `/boot` partition of the SD card. The Pi will enable SSH automatically on first boot. |
| 27 | + |
| 28 | +### Find Your Pi's IP Address |
| 29 | + |
| 30 | +From another device on the same network, you can find the Pi's IP with: |
| 31 | + |
| 32 | +```bash |
| 33 | +ping raspberrypi.local |
| 34 | +``` |
| 35 | + |
| 36 | +Or check your router's DHCP table. The Pi's hostname is `raspberrypi` by default (or whatever you set it to). |
| 37 | + |
| 38 | +!!! tip "Set a static IP" |
| 39 | + For a device you'll connect to regularly, assign a static IP in your router's DHCP settings or configure a static address on the Pi itself. This way the address never changes. |
| 40 | + |
| 41 | +## Add the Connection in WebSSH |
| 42 | + |
| 43 | +1. Open **WebSSH** on your iPhone or iPad |
| 44 | +2. Tap **+** to create a new connection |
| 45 | +3. Fill in the fields: |
| 46 | + - **Name:** e.g. `Pi - Home Lab` |
| 47 | + - **Host:** your Pi's IP address or `raspberrypi.local` |
| 48 | + - **Port:** `22` (default) |
| 49 | + - **Username:** `pi` (default) or whatever user you created |
| 50 | +4. Choose **Password** or **Private Key** for authentication |
| 51 | +5. Tap **Save**, then tap the connection to connect |
| 52 | + |
| 53 | +!!! warning "Change the default password" |
| 54 | + The default `pi` user with password `raspberry` is well known. If you haven't already, change it with `passwd` before exposing SSH to any network. |
| 55 | + |
| 56 | +## Use Key-Based Authentication (Recommended) |
| 57 | + |
| 58 | +A private key is both more secure and more convenient than a password. Here's how to set it up using WebSSH: |
| 59 | + |
| 60 | +**Step 1 — Generate a key in WebSSH:** |
| 61 | + |
| 62 | +1. Go to **Settings** (gear icon) |
| 63 | +2. Tap **SSH Keys → + → Generate** |
| 64 | +3. Choose **ED25519** |
| 65 | +4. Tap the key to copy the public key |
| 66 | + |
| 67 | +**Step 2 — Authorize the key on the Pi:** |
| 68 | + |
| 69 | +Connect once with a password, then run: |
| 70 | + |
| 71 | +```bash |
| 72 | +mkdir -p ~/.ssh |
| 73 | +echo "PASTE_YOUR_PUBLIC_KEY_HERE" >> ~/.ssh/authorized_keys |
| 74 | +chmod 700 ~/.ssh |
| 75 | +chmod 600 ~/.ssh/authorized_keys |
| 76 | +``` |
| 77 | + |
| 78 | +**Step 3 — Update your WebSSH connection:** |
| 79 | + |
| 80 | +Edit the connection and switch authentication to your private key. You won't be asked for a password again. |
| 81 | + |
| 82 | +## Connecting to Your Pi from Outside Your Home |
| 83 | + |
| 84 | +By default, your Pi is only reachable from your local network. To reach it from anywhere: |
| 85 | + |
| 86 | +**Option 1 — Port forwarding (simple, less secure):** |
| 87 | + |
| 88 | +Forward port `22` (or a custom port) from your router to the Pi's local IP. Then connect using your public IP or a dynamic DNS hostname. |
| 89 | + |
| 90 | +!!! warning "If you expose SSH to the internet" |
| 91 | + Use key-based auth only. Disable password authentication in `/etc/ssh/sshd_config` by setting `PasswordAuthentication no`. |
| 92 | + |
| 93 | +**Option 2 — SSH tunnel through a VPS (more secure):** |
| 94 | + |
| 95 | +If you have a cheap VPS or cloud server, you can set up a reverse tunnel so the Pi connects outward to the VPS, and you SSH into the VPS to reach the Pi. This avoids opening any ports on your home router. |
| 96 | + |
| 97 | +**Option 3 — Tailscale or WireGuard:** |
| 98 | + |
| 99 | +Install a VPN like Tailscale on the Pi and your iPhone. No port forwarding needed; everything is encrypted peer-to-peer. |
| 100 | + |
| 101 | +## Multiple Terminals at Once |
| 102 | + |
| 103 | +WebSSH lets you open multiple SSH sessions simultaneously. Useful when you need one terminal for logs and another for commands: |
| 104 | + |
| 105 | +1. Connect to your Pi |
| 106 | +2. Tap the terminal icon to open another session |
| 107 | +3. See [Launching Multiple Terminals](/documentation/help/howtos/launching-multiple-terminals/) for details |
| 108 | + |
| 109 | +## Troubleshooting |
| 110 | + |
| 111 | +??? question "ssh: connect to host raspberrypi.local port 22: Connection refused" |
| 112 | + SSH is not enabled. Connect a monitor and keyboard to the Pi, run `sudo raspi-config` and enable SSH under Interface Options. |
| 113 | + |
| 114 | +??? question "raspberrypi.local doesn't resolve" |
| 115 | + mDNS (Bonjour) may not be working on your network. Use the Pi's IP address directly instead. Find it in your router's DHCP table or run `hostname -I` on the Pi. |
| 116 | + |
| 117 | +??? question "Permission denied (publickey)" |
| 118 | + The public key isn't correctly installed on the Pi. Check that `~/.ssh/authorized_keys` contains your key, and that permissions are `700` for `~/.ssh` and `600` for `authorized_keys`. |
| 119 | + |
| 120 | +??? question "Connection drops when I switch apps" |
| 121 | + This is an iOS background execution limit. On iPad, use Split View or Slide Over to keep WebSSH visible. See [tmux](/documentation/help/howtos/tmux/create-attach-existing-tmux-session/) to keep your session alive server-side regardless of the iOS connection state. |
| 122 | + |
| 123 | +## Related Documentation |
| 124 | + |
| 125 | +- [SSH Public / Private Key Pair](/documentation/help/SSH/public-private-key/) |
| 126 | +- [Local Port Forwarding](/documentation/help/networking/local-port-forwarding/) — access services running on the Pi (web UI, databases, etc.) |
| 127 | +- [tmux — Create or Attach to an Existing Session](/documentation/help/howtos/tmux/create-attach-existing-tmux-session/) |
| 128 | +- [Launching Multiple Terminals](/documentation/help/howtos/launching-multiple-terminals/) |
0 commit comments