我有一个很less连接到的ssh服务器,它需要使用不同的用户login到我的系统。 当我执行ssh example.com ssh会自动使用我的默认用户[email protected]进行连接。 这是行不通的,因为服务器期望我与一个特殊用户[email protected]连接。 此外,该服务器有一个强大的阻止和禁止政策。 所以当我多次使用错误的密码的时候,我会自动封锁半个小时甚至被禁止。 因为我很less连接,所以我会忘记我需要用一个特殊的用户来连接,如果我被阻塞了半个小时,甚至被禁止,这可能是非常烦人的。
我正在寻找的是一种configuration我的本地SSH客户端的方式,并告诉它: “当我连接到example.com,我希望你自动连接用户xyz12345,而不是我的当前用户。
是这样的可能吗?
你可以在你的ssh客户端configuration中进行设置。
添加到你的.ssh/config
Host example.com User xyz12345
从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.
我会在~/.<shell>rc脚本中使用一个别名:
alias mycmd='ssh [email protected]'
然后input:
source ~/.<shell>rc
但是你也可以这样做: 更好的方法