使用 Plink 在另一台服务器(jumphost)后面的远程服务器上执行命令

2023-11-30

我正在尝试使用 Power Automate Desktop for PuTTY 进行自动化。我遇到了一个使用 cmd 来运行命令的解决方案plink。 我使用了以下步骤:

  1. 我将PuTTY添加到系统变量中

  2. 我使用了命令(在cmd中):

    plink -ssh hostname@ipaddress -pw password -no-antispoof -m C:\commands.txt
    
  3. 我编辑过command.txt:

    ssh anotherIP -pw passwordForAnotherIP
    cd /tmp
    cat filename
    

当我在cmd中运行命令时,我无法输入需要在第一个服务器内访问的其他服务器的密码。显示的错误是

坏端口“w”

服务器运行 bash 4.2。如何在txt文件命令中输入密码以便命令行plink命令接受它吗?


更好的解决方案是使用Plink's -proxycmd:

plink -ssh anotherIP -pw passwordForAnotherIP -no-antispoof -proxycmd "plink -ssh hostname@ipaddress -pw password -nc anotherIP:22" -m C:\commands.txt

随着commands.txt仅包含:

cd /tmp
cat filename

回答你的字面问题:

OpenSSHssh has no -pw转变。看使用脚本自动输入 SSH 密码.

此外,您的command.txt无论如何都不会按照你的想法去做。它不会运行cd and catssh。它会运行他们after the ssh。所以关于ipaddress。如何正确执行此操作将在以下内容中讨论:建立连接后通过Plink输入密码远程ssh.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 Plink 在另一台服务器(jumphost)后面的远程服务器上执行命令 的相关文章

随机推荐