Skip to content

SSH — mihomo

mihomo 提供 SSH 客户端出站。仅客户端 —— 没有 SSH 服务端入站。

出站

proxies:type: ssh 条目。内嵌 BasicOption

字段类型默认值允许值描述
namestring(required)<string>唯一的代理名。
serverstring(required)<host>SSH 服务器主机名或 IP。
portint(required)<port>SSH 服务器端口(按惯例 22)。
usernamestring(required)<string>SSH 登录名。
passwordstring(unset)<string>密码鉴权。与 `private-key` 二选一。
private-keystring(unset)<PEM block or file path>密钥鉴权。接受内联 PEM 块或文件路径;mihomo 自动识别格式。
private-key-passphrasestring(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 是 OpenSSH known_hosts 格式。空列表意味着首次连接信任 —— 切勿在无人值守部署中启用。
  • SSH 出站 支持多路复用 —— 每条连接都开新的 SSH 会话。若希望 通过另一传输多路复用,可配合 mihomo 的 dialer-proxy 链式拨号。

跨内核说明

  • Xray-core 没有 SSH 出站。参见 SSH — Xray-core
  • sing-box 使用 user(而非 username),其余为 snake_case (private_keyhost_key_algorithms),并接受内联密钥列表以便 轮换;还暴露了 client_version 横幅字段。参见 SSH — sing-box

源码: adapter/outbound/ssh.go:31-42 · v1.19.27 (5184081)

由 Argsment 出品的 Core Tutorial