How to SSH into a server from your iPhone or iPad safely
Keys instead of passwords, host-key fingerprints you actually verify, and a few settings on the server side that make a phone a reasonable place to run a shell when something breaks.
Published: 4 min read
Most people open a terminal on their phone for the same reason: something broke while they were away from a laptop. That is exactly the moment to be careful, because a hurried SSH session from a mobile device is where password reuse, unverified hosts and keys copied through a chat app tend to happen.
This guide sets up an SSH connection from an iPhone or iPad the way you would from a workstation: an Ed25519 key with a passphrase, a host fingerprint you have compared against the real one, and a server configured to refuse anything weaker. The steps use DevKit's terminal, but the server-side advice applies to any client.
Use a key, not a password
Password logins are the first thing an attacker tries and the easiest thing to mistype on a touch keyboard. A key pair fixes both: the private half never leaves the device, and the server only ever sees a signature. Ed25519 keys are short, fast and supported by every current OpenSSH release, which is why DevKit works with Ed25519 keys in OpenSSH format, including keys protected by a passphrase.
You can generate the key on the device itself. DevKit shows you the public half to install on the server, and the private half is stored in the device's Keychain, marked device-only, so it is not copied to other devices or to DevKit's servers. If you already have a key on a workstation, prefer generating a fresh one for the phone instead of transferring the existing private key through email or a chat app; one key per device makes revoking a lost phone a single line edit.
- Generate an Ed25519 key in DevKit, or on a workstation with ssh-keygen -t ed25519.
- Copy the public key into ~/.ssh/authorized_keys on the server and make sure the file is mode 600 and the .ssh directory is mode 700.
- Connect with the key once and confirm it works before you change anything else on the server.
Verify the host key the first time
On the first connection DevKit shows the server's host key fingerprint and asks you to confirm it. Do not tap through this. Compare it with the fingerprint printed on the server itself, for example with ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub from a session you already trust, or with the value your hosting provider shows in its console.
Once confirmed, the server is remembered. If its key changes later, which happens after a reinstall but also during a man-in-the-middle attack, DevKit refuses the connection until you remove the server from Settings › Trusted servers. Treat that refusal as a question, not an obstacle: find out why the key changed before you clear it.
Harden the server once key login works
- Set PasswordAuthentication no and PubkeyAuthentication yes in /etc/ssh/sshd_config, then reload the SSH service. Keep your current session open while you test a new one, so a typo cannot lock you out.
- Set PermitRootLogin no and use a normal user with sudo. Root over SSH from a phone is a bad combination of high privilege and small keyboard.
- Keep the server's time correct and its OpenSSH package updated; many connection problems that look like client bugs are an old sshd rejecting modern defaults.
- Remember that DevKit does not offer SFTP, port forwarding or tunnels. If you need those, do them from a workstation rather than working around the limit.
Working in the terminal on a phone
The small screen is the real constraint, so lean on the things the app does to compensate. DevKit keeps up to four sessions open, has a row of Esc, Ctrl, Tab and arrow keys above the keyboard, and lets you save commands you type often, which turns a long journalctl invocation into a tap. vim, htop and nano work as expected. On iPad the terminal uses the whole screen and the sidebar keeps projects, monitors and tools one tap away.
Two things worth knowing in advance. iOS ends SSH connections shortly after the app goes to the background; DevKit offers to reconnect, but it opens a new shell, so run anything long inside tmux or screen on the server. And credentials are saved to the Keychain only if you choose to after a successful connection, so decide once whether this device should remember the key or ask for it every time. Nothing you type in a terminal is recorded.
Before you open a shell at all, check whether you need to. DevKit's server summary runs over the same SSH connection and reports uptime, load, memory, disks, failed services and Docker containers in one tap, which answers the most common 3 a.m. questions without a single command.