鸿蒙手机怎么连服务器?HarmonyOS SSH 客户端指南How to SSH into a Server from a HarmonyOS Phone
服务器半夜告警,手边只有一台鸿蒙手机——这时候能不能连上去看一眼,决定了你是现在处理还是爬起来开电脑。本文讲清楚鸿蒙 NEXT 上用 SSH 连服务器的完整流程。
鸿蒙上的 SSH 现状
鸿蒙 NEXT 不再兼容 Android 应用,这意味着过去在安卓上用惯的那些 SSH 工具需要重新寻找原生替代。好消息是原生鸿蒙的终端类应用正在补齐,Shellby 就是其中之一——它在华为应用市场上架,支持手机与平板,系统要求 HarmonyOS 5.1 及以上。
连接前你需要三样信息
- 服务器地址——域名或 IP,例如
example.com或203.0.113.10。 - 端口——默认 22。如果运维改过,问一下或查服务器上的
/etc/ssh/sshd_config。 - 用户名 + 认证方式——用户名如
root、ubuntu、ec2-user;认证要么是密码,要么是一把私钥。
三步连上
- 新建主机——打开应用,点右下角的「+」。
- 填写连接信息——地址、端口、用户名,然后选认证方式:
- 密码:直接输入登录密码,适合临时连一台机器。
- 密钥:选一把已有的私钥,或就地新建 / 导入。云服务器(阿里云、腾讯云、AWS 等)默认多用密钥登录。
- 测试并保存——先点「测试连接」验证信息无误,再保存。保存后会自动发起连接。
首次连接会弹出主机指纹确认。这一步不是走过场:它是 SSH 防中间人攻击的关键环节,请核对指纹与服务器端 ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub 的输出一致后再信任。
手机上的终端体验
手机没有 Ctrl、Tab、方向键,所以终端顶部通常会有一条快捷键栏——Ctrl+C 中断、Tab 补全、上下方向键翻历史命令,都靠它。长按可以选中文字复制。
另一个现实问题是网络切换:从 Wi-Fi 走到电梯里切成蜂窝,普通 SSH 连接会断。这时候「回到应用自动重连」就很重要——重连会保留你本地看到的滚动历史,但远端的进程状态不会恢复,所以长任务建议放进 tmux 或 screen 再跑。
手机上值得记住的几条命令
uptime/top——看负载,判断是不是被打满了df -h——看磁盘,很多"服务挂了"其实是磁盘写满journalctl -u nginx -n 100 --no-pager——看某个服务最近的日志systemctl restart nginx——重启服务(先想清楚再敲)
把常用的几条存成命令片段,下次一键发送,比在小键盘上敲一长串靠谱得多。
不只是敲命令
连上之后能做的比想象中多:SFTP 浏览远端目录、上传下载文件(支持断点续传);服务器监控把 CPU、内存、磁盘、负载和进程列表放在一屏里;端口转发用来访问你自己服务器上只监听本地的服务,比如没有对公网开放的数据库管理页面。
常见问题
连不上,提示 Connection refused?
通常是三种情况:端口写错了、服务器防火墙没放行、或者 sshd 没在跑。先确认端口,再检查安全组 / ufw 规则。
提示 Permission denied (publickey)?
服务器只接受密钥登录,而你用了密码,或者用错了私钥。确认这台机器的 ~/.ssh/authorized_keys 里有你这把密钥的公钥。
私钥怎么弄到手机上?
可以直接在手机上生成一把新的 Ed25519 密钥,把公钥贴到服务器的 authorized_keys——这样私钥从一开始就没离开过设备,比从电脑上导出再传过来更安全。具体见SSH 密钥入门。
鸿蒙版的能力边界
说清楚免得你装完才发现:鸿蒙版目前全部功能免费、不含应用内购买,也暂不包含 AI 助手(生成式 AI 在国内需完成算法备案,会在后续版本开放)。SSH 终端、SFTP、端口转发、服务器监控、密钥管理与可选的多端同步都可以正常使用。
An alert fires at 2am and all you have is your phone. Whether you can get a shell on that box decides if you handle it now or get out of bed. Here's the full path to connecting over SSH from HarmonyOS NEXT.
The state of SSH on HarmonyOS
HarmonyOS NEXT no longer runs Android apps, so the SSH tools you were used to need native replacements. Terminal apps are catching up — Shellby is one of them, published on Huawei AppGallery for both phone and tablet, requiring HarmonyOS 5.1 or later.
Three things you need first
- Server address — a hostname or IP, e.g.
example.comor203.0.113.10. - Port — 22 by default; check
/etc/ssh/sshd_configif someone changed it. - Username + auth method —
root,ubuntu,ec2-user…, then either a password or a private key.
Connecting in three steps
- Add a host — open the app and use the “+” button.
- Fill in the details — address, port, username, then pick how you authenticate:
- Password — fine for a one-off box.
- Key — pick an existing private key, or create / import one right there. Cloud servers almost always default to key auth.
- Test, then save — run “Test Connection” before saving; saving connects automatically.
The first connection asks you to verify the host fingerprint. Don't rubber-stamp it: this is the step that stops man-in-the-middle attacks. Compare it against ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub on the server.
Living in a terminal on a phone
Phones have no Ctrl, Tab or arrow keys, so a shortcut bar above the keyboard does that work — Ctrl+C to interrupt, Tab to complete, arrows for command history. Long-press to select and copy.
The other reality is network switching: walk into an elevator, Wi-Fi drops to cellular, and a plain SSH session dies. Reconnecting on return keeps the scrollback you can see locally, but not the remote process state — so run long jobs inside tmux or screen.
Commands worth keeping around
uptime/top— is the box simply saturated?df -h— a surprising share of “the service is down” is a full diskjournalctl -u nginx -n 100 --no-pager— recent logs for one servicesystemctl restart nginx— restart it (think first)
Save the ones you use often as snippets and send them with a tap — far better than typing a long line on a phone keyboard.
More than a shell
Once connected: SFTP to browse remote directories and transfer files with resumable uploads/downloads; server monitoring putting CPU, memory, disk, load and top processes on one screen; port forwarding to reach services on your own server that only listen on localhost — a database admin page you deliberately never exposed publicly, for instance.
FAQ
Connection refused?
Usually one of three: wrong port, firewall not open, or sshd isn't running. Check the port first, then your security group or ufw rules.
Permission denied (publickey)?
The server only accepts keys and you tried a password — or you used the wrong key. Make sure your public key is in that machine's ~/.ssh/authorized_keys.
How do I get a private key onto the phone?
Generate a fresh Ed25519 key on the phone and paste its public half into authorized_keys. That way the private key never leaves the device — safer than exporting from a computer and shipping it over. See the key guide.
What the HarmonyOS build does and doesn't have
So you know before installing: the HarmonyOS build is entirely free with no in-app purchases, and it does not currently include the AI assistant (generative AI requires algorithm filing in mainland China; it will arrive in a later update). SSH terminal, SFTP, port forwarding, server monitoring, key management and optional multi-device sync all work.