【发布时间】:2022-11-09 00:49:48
【问题描述】:
我知道这个问题已被多次提出(https://superuser.com/questions/606252/how-to-use-sshpass-for-chained-connection 和https://unix.stackexchange.com/questions/320412/how-to-use-sshpass-to-supply-a-password-on-the-second-ssh-hop),但我发现的所有解决方案都不起作用。 我正在尝试使用 sshpass 访问第三台机器(third@machine),以免被提示插入密码。但是,在进入决赛之前必须使用桥接机(bridge@machine)。 每次我需要输入bridge@machine和third@machine的密码,所以我的工作流程是:
ssh 网桥@机器
插入密码:
ssh 第三@机器
插入密码
到目前为止,我可以通过在 ~.ssh/config 文件中的 proxycommand 中使用 sshpass 来避免使用第一个密码,如下所示:
vi ~.ssh/config :
Host *.reference User example_user ProxyCommand sshpass -p $bridge_machine_password$ ssh -o StrictHostKeyChecking=no bridge@machine "nc -w 60 `basename %h .reference` %p"和当代我在 .bashrc 文件中定义了一个名为“curie”的别名:
别名居里='ssh third@machine.reference'
因此,如果运行别名 curie,我可以避免使用第一个密码,但仍会提示我输入第三个@machine 的密码。
出于这个原因,我尝试使用 sshpass 通过以下方式访问 third@machine:
>sshpass -p 'third_machine_password' ssh -oProxyCommand="ssh -W %h:%p bridge@machine" third@machine不幸的是,这回馈了:
Permission denied, please try again.可能是第三个@machine 施加的限制,或者我做错了什么?
【问题讨论】: