OnepilotDownload
Onepilot mascot

How to SSH From an iPhone: Setup, Keys, and Staying Connected

Connect to a server from an iPhone: what you need, how to generate and install a key from the phone, reaching a Mac or a Pi, and why the session drops when the phone locks.

sofiane8910

by sofiane8910 · February 11, 2026 · 9 min read · updated July 25, 2026

Onepilot runs these agents from your iPhone, download it on the App Store.

Reaching a server from your phone is a genuinely useful skill, and the setup takes about ten minutes once. This covers what you need, how to handle keys without a laptop, the specific cases people ask about most, and the one problem that catches everybody out.

A quick disambiguation first, because two very different questions share the same words. This guide is about using an iPhone as an SSH client to reach a server. If you are trying to SSH into an iPhone, that requires a jailbroken device running its own SSH daemon, and none of this applies.

Can you SSH from an iPhone?

Yes, and with no compromises on the protocol side. iOS SSH clients give you a real interactive terminal running a real login shell, speaking standard SSH. The server cannot tell a phone from a laptop and needs no special configuration to accept one.

What differs is everything around the connection. A touch keyboard has no Ctrl, Esc, Tab, or arrow keys, so clients add a key bar to supply them. Screen space means long command output wraps hard. And iOS suspends backgrounded apps, which ends sessions in a way desktops never do. The first two are annoyances you adapt to within a day. The third is structural and is covered further down.

What do you need before you start?

How do you SSH into a server from an iPhone?

The flow is the same in every client. Install one from the App Store, add a host with its address, port (22 unless someone changed it), and username, pick your authentication method, and connect. You land in your normal login shell.

Two things worth getting right the first time. Check the host key fingerprint when the client shows it on first connect. That prompt is the one moment SSH asks you to verify you are talking to the machine you think you are, and tapping through it blindly defeats the protection. Compare it against ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub run on the server. And use the right username, which on cloud images is rarely root: Ubuntu images use ubuntu, Amazon Linux uses ec2-user, Debian uses debian or admin. A correct key with the wrong username fails in a way that looks like a broken key.

How do you generate an SSH key on an iPhone?

In the client. Every serious iOS SSH app can create a keypair on the device, generally under a keys or identities screen. Pick ed25519 rather than RSA. The keys are shorter, faster to verify, and sidestep the SHA-1 signature deprecation that stops older ssh-rsa keys working against OpenSSH 8.8 and later, a failure that surprises people whose key worked for years.

The private key stays in the iOS Keychain, protected by the Secure Enclave, and never has to leave the phone. Only the public half travels. Getting that public half onto the server is the fiddly part when the phone is all you have:

Watch for line breaks. A public key is one single line, and an editor or messaging app that wraps it produces a key that silently never matches. If it does not work, Permission denied (publickey) walks through the causes in order.

How do you SSH from an iPhone to a Mac or a Raspberry Pi?

To a Mac

Turn on Remote Login on the Mac in System Settings under General, then Sharing. That starts the OpenSSH server already built into macOS and displays the address to use. Connect from the phone to that address on port 22 with your macOS account name, and authenticate with your login password or a key you have installed.

To a Raspberry Pi

SSH is off by default on Raspberry Pi OS. Enable it with sudo raspi-config under Interface Options, or, for a headless setup before first boot, put an empty file named ssh in the boot partition of the SD card. Connect as the user created during setup. Key-based authentication matters more here than anywhere else, because a Pi is the machine most likely to end up exposed to the wider internet with a weak password.

To either, from outside your home network

Both sit behind NAT with no public address, so neither is reachable from outside without help. That is a networking problem rather than an SSH one, and it has four possible answers, compared in SSH without port forwarding.

Why does the session drop when you lock the phone?

Two causes, and neither is a bug in your client.

iOS gives an app a short grace period after it leaves the foreground and then stops scheduling it entirely. The socket goes unserviced, the server eventually gives up, and by the time you reopen the app there is nothing to resume. Separately, moving between wifi and cellular changes your source IP address, and since a TCP connection is defined by its address pair, changing one ends the connection instantly. Walking out of your front door is enough.

Keepalives help with idle timeouts but cannot save you from either of these. Two things genuinely work:

The full picture, including what client_loop: send disconnect: broken pipe is really telling you, is in why SSH sessions keep disconnecting.

Which SSH client should you use on iPhone?

The established options each optimise for something different. Termius is the polished all-rounder with cross-device sync and SFTP. Blink Shell is open source, keyboard-first, and has the best Mosh support on the platform. Prompt from Panic is the minimal, well-made choice if you want a terminal and nothing else.

What actually separates them in daily use is not terminal quality, which is good across the board, but three things worth checking before you commit: how good the key bar is, since you will press Ctrl and Esc constantly; whether it can generate and store keys on device; and what happens when the connection drops, because that is the interaction you will have most often.

How do you keep SSH secure from a phone?

  1. Use keys, not passwords. Then disable password auth server side with PasswordAuthentication no in /etc/ssh/sshd_config, which removes brute forcing as a threat entirely.
  2. Set a passcode and biometrics on the phone. Your keys live in the Keychain, so device security is server security.
  3. Verify host key fingerprints on first connect, and treat a changed fingerprint as a real warning rather than something to dismiss.
  4. Do not disable host key checking to make an error go away. It exists to detect exactly the attack it looks like.
  5. Use a jump host for production. Reaching sensitive infrastructure through a bastion rather than exposing each machine is worth the extra hop.
  6. Keep a second key from another device. A lost phone should not mean a lost server.

Editing sshd_config from a phone deserves one specific warning: keep your current session open while you test the change in a second connection. An existing session survives a broken config, so you always have a way back until you disconnect.

Can you SSH from an iPad?

Yes, and everything above applies unchanged, since iPadOS runs the same clients. The differences are all in your favour: more room for output, Split View alongside documentation, and hardware keyboard support that gives you back the modifier keys. The one thing that does not improve is app suspension, which behaves exactly as it does on iPhone.

The short version

Generate an ed25519 key in your client, get the public half into ~/.ssh/authorized_keys with 600 permissions, connect with the right username, and verify the host key the first time. Expect the session to drop when you lock the phone or change networks, and run anything that matters inside tmux so it does not cost you.

That last point is the one worth designing around rather than working around, which is what Onepilot does differently: shells run in a daemon on the host rather than inside the phone's connection, so backgrounding the app or switching from wifi to cellular leaves the session running and reconnecting replays what you missed, with no reattach command to type. It pairs a server by scanning a code the host prints, so there is no key to move by hand either. For choosing between the established clients, see the Termius vs Blink Shell comparison.

FAQ

Can you SSH from an iPhone?

Yes. iOS runs full SSH clients that give you a real interactive terminal, not a cut-down remote control, and the protocol is identical to the one your laptop speaks. The server cannot tell the difference and needs no special configuration. What differs is the client experience: a touch keyboard with no Ctrl or Esc key until the app provides one, and an operating system that suspends backgrounded apps, which is what ends sessions when you switch away.

How do you generate an SSH key on an iPhone?

Every serious iOS SSH client can generate a keypair on the device, usually under a keys or identities section in its settings. Choose ed25519 over RSA: the keys are shorter, faster, and avoid the SHA-1 signature deprecation that breaks older RSA keys against OpenSSH 8.8 and later. The private key stays in the iOS Keychain and never needs to leave the phone; you only copy the public half to the server.

How do you SSH from an iPhone to a Mac?

On the Mac, turn on Remote Login in System Settings under General, then Sharing, which starts the OpenSSH server built into macOS. Note the address it displays. From the iPhone, connect to that address on port 22 with your macOS account name. On the same wifi network this works straight away. From outside the network the Mac sits behind NAT with no public address, which is a reachability problem rather than an SSH one.

Why does my SSH session drop when I lock my iPhone?

Because iOS suspends apps shortly after they leave the foreground, so the app stops servicing the network socket and the connection times out. Switching from wifi to cellular breaks it faster still, since changing your source IP address invalidates the TCP connection outright. No client setting prevents either. The durable fix is to run your work inside tmux on the server so the shell survives independently of the connection.

Related reading

Run your AI agents from your iPhone

Download Onepilot on the App Store.

See also: the three-layer agent overview, run Hermes on iPhone, or all articles.