使用ssh时定义传出IP地址

Mar*_*ark 6 ssh

我有一台 ubuntu 服务器机器 (12.04),有 4 个 IP 地址,用于需要唯一 ssl 证书的不同网站。

我有时会从这个盒子和我要去的盒子 ssh 出去,我必须告诉它我将来自哪个 IP 地址。

如何指定要使用的 4 个 IP 地址中的哪一个作为我的传出 IP 地址?

如果我做一个 ifconfig 看起来我是作为最后一个 ipaddress 出去的。

我猜你想指定地址或接口....

提前致谢!

-标记

jdt*_*ood 10

From ssh(1)

 -b bind_address
         Use bind_address on the local machine as the source address of
         the connection.  Only useful on systems with more than one
         address.
Run Code Online (Sandbox Code Playgroud)

如果这不能满足您的要求,那么您将不得不以ip route首选接口用于连接的方式配置路由(使用)。

  • @JamieHutber - `ssh -b 192.154.12.1 用户名@destinationhost` (2认同)