在 iPhone / iPad 上连接服务器:SSH 客户端入门SSH from iPhone and iPad: A Practical Starter Guide
把服务器装进口袋,听起来像应急手段,用顺了会发现它替代了不少"非得回到电脑前"的时刻。这篇讲清楚在 iPhone / iPad 上连服务器要准备什么、会遇到什么。
先准备好这些
连接一台服务器最少需要:地址(域名或 IP)、端口(默认 22)、用户名,以及一种认证方式。
认证方式只有两类,值得先想清楚:
- 密码——最直接,适合临时连一台内网机器。缺点是可被暴力破解,公网机器不推荐长期这么用。
- 密钥——一对文件,公钥放服务器、私钥留在你手上。安全性高得多,云服务器默认都是这种。详见SSH 密钥入门。
第一次连接:指纹这一步别跳过
首次连上一台新服务器时,客户端会显示一串主机指纹并要你确认。它的作用是确认"我连上的确实是那台机器",而不是中间某个冒充者。
正确做法是在服务器上跑一次 ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub,把输出和手机上显示的比对。之后这台机器的指纹会被记住;如果哪天它变了并弹出强警告,别顺手点确认——要么服务器重装 / 换了主机密钥,要么有人在中间。先去问清楚。
移动端特有的几个坑
没有 Ctrl 和方向键
iOS 软键盘没有这些键,所以终端上方通常有一条快捷键栏。Ctrl+C 中断当前命令、Ctrl+D 退出、Tab 补全、上下键翻历史,都在那儿。接了外接键盘的 iPad 则可以直接用实体键。
会话会断
手机切网、锁屏、App 进后台一段时间,连接都可能断掉。两个应对办法:一是把长任务放进 tmux / screen,断了重连还能 tmux attach 回去;二是改用能在切网后自动续上的 Mosh 兼容连接。
复制粘贴
终端里长按可以选中文字。经常复制的话,「选中即复制」这类设置能省一步操作。反过来,把手机上的内容粘进终端也很常用——比如把一段配置贴进 vim,注意先进入插入模式,并留意自动缩进把格式搞乱(:set paste 能避免)。
iPad 上可以更进一步
屏幕大了,用法就不只是"应急":多个会话用标签管理,横屏下可以分屏并排看两台机器的输出;批量运维时,命令广播能把同一条命令同时发给多个会话——滚动重启或统一改配置很省事。
不止终端
- SFTP:浏览远端目录、上传下载,改配置文件不必全靠
vim。 - 服务器监控:CPU、内存、磁盘、负载、进程一屏看完,比挨个敲命令快。
- 端口转发:访问你自己服务器上只监听本地的服务,例如未对公网开放的管理后台。
- 跳板机:先连堡垒机再跳到内网目标机,用 ProxyJump 一步配好。
安全上的几条建议
- 优先用密钥登录,并给私钥设口令。
- 私钥应存在系统钥匙串这类受设备解锁保护的地方,不要以明文躺在文件里。
- 开启应用锁(生物识别),手机丢了不至于连带服务器一起丢。
- 公网服务器建议关掉密码登录(
PasswordAuthentication no),只留密钥。
关于 Shellby
上面这些能力 Shellby 在 iPhone / iPad / Mac 上都有,一次下载三端通用,最低要求 iOS / iPadOS 17 与 macOS 15。凭据存入系统钥匙串,配置本地保存、无需账号。
Putting your servers in your pocket sounds like an emergency measure. Used for a while, it quietly replaces a lot of “I'll have to get back to my desk” moments.
What you need
At minimum: an address (hostname or IP), a port (22 by default), a username, and a way to authenticate.
- Password — simplest, fine for a box on your own network. Brute-forceable, so not a great long-term answer for anything public.
- Key — a pair of files: the public half on the server, the private half with you. Much stronger, and the default for cloud servers. See the key guide.
The fingerprint step is not a formality
Connecting to a new server shows a host fingerprint to confirm. It answers “am I really talking to that machine, or to someone in the middle?”
Run ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub on the server and compare. The fingerprint is remembered afterwards — and if it ever changes and you get a loud warning, don't wave it through. Either the server was rebuilt or rotated its host key, or someone is in the middle. Find out which.
Mobile-specific friction
No Ctrl, no arrow keys
The iOS keyboard has neither, so terminals add a shortcut bar: Ctrl+C to interrupt, Ctrl+D to exit, Tab to complete, arrows for history. An iPad with a hardware keyboard just uses the real keys.
Sessions drop
Switching networks, locking the screen, or backgrounding the app can all kill a connection. Two answers: run long jobs inside tmux / screen so you can tmux attach after reconnecting — or use a Mosh-compatible connection that survives the network change.
Copy and paste
Long-press to select in the terminal; a “copy on select” option saves a step if you do it often. Pasting in is just as common — when dropping config into vim, enter insert mode first and watch out for auto-indent mangling it (:set paste avoids that).
iPad earns its screen
With room to work it stops being an emergency tool: tabs for multiple sessions, split view to watch two machines side by side, and command broadcast to send one command to several sessions at once — handy for rolling restarts or a config change across a fleet.
Beyond the shell
- SFTP — browse, upload and download; editing config doesn't have to mean
vim. - Monitoring — CPU, memory, disk, load and processes on one screen.
- Port forwarding — reach services on your own server that only listen on localhost, such as an admin panel you never exposed publicly.
- Jump hosts — hop through a bastion to an internal machine with ProxyJump.
A few security habits
- Prefer keys, and put a passphrase on the private key.
- Keep private keys in the system Keychain — protected by device unlock, not sitting in a plaintext file.
- Turn on the app lock (biometrics) so a lost phone isn't a lost server.
- On public servers, disable password login (
PasswordAuthentication no) and keep keys only.
About Shellby
Shellby does all of the above across iPhone, iPad and Mac — one download for all three, requiring iOS / iPadOS 17 and macOS 15. Credentials go into the system Keychain; configuration stays on device and no account is needed.