SSH — mihomo
mihomo 提供 SSH 客户端出站。仅客户端 —— 没有 SSH 服务端入站。
出站
proxies: 下 type: ssh 条目。内嵌 BasicOption。
| 字段 | 类型 | 默认值 | 允许值 | 描述 |
|---|---|---|---|---|
name | string | (required) | <string> | 唯一的代理名。 |
server | string | (required) | <host> | SSH 服务器主机名或 IP。 |
port | int | (required) | <port> | SSH 服务器端口(按惯例 22)。 |
username | string | (required) | <string> | SSH 登录名。 |
password | string | (unset) | <string> | 密码鉴权。与 `private-key` 二选一。 |
private-key | string | (unset) | <PEM block or file path> | 密钥鉴权。接受内联 PEM 块或文件路径;mihomo 自动识别格式。 |
private-key-passphrase | string | (unset) | <string> | 加密私钥的 passphrase。 |
host-key | []string | [] | <known_hosts line> | 期望的主机密钥,OpenSSH known_hosts 格式。空值禁用校验 —— 仅供测试。 |
host-key-algorithms | []string | (library default) | <algo> | 限制客户端可接受的主机密钥算法。 |
源码: adapter/outbound/ssh.go:31-42 · 锚定版本 v1.19.27 (5184081)
示例
密钥鉴权:
yaml
proxies:
- name: ssh-server
type: ssh
server: ssh.example.com
port: 22
username: alice
private-key: /etc/mihomo/id_ed25519
private-key-passphrase: <passphrase>
host-key:
- ssh.example.com ssh-ed25519 AAAA...带显式算法的内联密钥:
yaml
proxies:
- name: ssh-strict
type: ssh
server: ssh.example.com
port: 22
username: alice
private-key: |
-----BEGIN OPENSSH PRIVATE KEY-----
<key bytes>
-----END OPENSSH PRIVATE KEY-----
host-key-algorithms:
- ssh-ed25519
- rsa-sha2-512说明
private-key同时接受内联 PEM 块或文件路径;mihomo 通过检测值中 是否含BEGIN判定。host-key是 OpenSSHknown_hosts格式。空列表意味着首次连接信任 —— 切勿在无人值守部署中启用。- SSH 出站 不 支持多路复用 —— 每条连接都开新的 SSH 会话。若希望 通过另一传输多路复用,可配合 mihomo 的
dialer-proxy链式拨号。
跨内核说明
- Xray-core 没有 SSH 出站。参见 SSH — Xray-core。
- sing-box 使用
user(而非username),其余为 snake_case (private_key、host_key_algorithms),并接受内联密钥列表以便 轮换;还暴露了client_version横幅字段。参见 SSH — sing-box。
源码: adapter/outbound/ssh.go:31-42 · v1.19.27 (5184081)
