问题描述
我正在尝试使用 Power Automate Desktop for PuTTY 进行自动化。我遇到了一个使用 cmd 使用 plink
运行命令的解决方案。
我使用了以下步骤:
-
我在系统变量中添加了 PuTTY
-
我使用了命令(在 cmd 中):
plink -ssh hostname@ipaddress -pw password -no-antispoof -m C:\commands.txt
-
我编辑了
command.txt
:ssh anotherIP -pw passwordForAnotherIP cd /tmp cat filename
当我在 cmd 中运行命令时,我无法在第一个服务器中输入需要访问的其他服务器的密码。显示的错误是
坏端口'w'
服务器运行 bash 4.2。如何在 txt 文件命令中输入密码,以便命令行 plink
命令接受它?
解决方法
OpenSSH ssh
没有 -pw
开关。见Automatically enter SSH password with script。
此外,您的 command.txt
无论如何都不会按照您的想法行事。它不会在 cd
中运行 cat
和 ssh
。它会在ssh
之后运行它们。所以在 ipaddress
上。
相反,您可以使用 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