自动设置SSH用户

lan*_*oxx 8 ssh

我有一台很少连接的 ssh 服务器,它需要使用与我用来登录系统的用户不同的用户。当我刚刚执行时,ssh example.comssh 将自动使用我的默认用户 foo@example.com 进行连接。这不起作用,因为服务器希望我与特殊用户连接xyz12345@example.com。此外,服务器具有强大的阻止和禁止策略。所以当我几次使用错误的密码时,然后我会自动被阻止半小时甚至被禁止。因为我很少连接,我往往会忘记我需要使用一个特殊的用户来连接,如果我被阻止半小时甚至被禁止会很烦人。

我正在寻找的是一种配置我的本地 ssh 客户端并告诉它的方法:“当我连接到 example.com 时,我希望您自动与用户 xyz12345 连接,而不是与我当前的用户连接。”

这样的事情可能吗?

baf*_*baf 33

您可以在 ssh 客户端配置中进行设置。

添加到您的 .ssh/config

Host example.com
     User xyz12345
Run Code Online (Sandbox Code Playgroud)

来自man ssh_config

User     Specifies the user to log in as. This can be useful when a dif-
         ferent user name is used on different machines.  This saves the
         trouble of having to remember to give the user name on the com-
         mand line.
Run Code Online (Sandbox Code Playgroud)