I am trying to make an automation using Power Automate Desktop for PuTTY. I have come across a solution to use cmd to run commands using plink
.
I used the following steps:
I added PuTTY to system variables
I used the command (in cmd):
plink -ssh hostname@ipaddress -pw password -no-antispoof -m C:\commands.txt
I edited command.txt
:
ssh anotherIP -pw passwordForAnotherIP
cd /tmp
cat filename
When I run the command in cmd, I can not input password for the other server that needs to be accessed inside the first one. The error shown is
Bad Port 'w'
The server runs bash 4.2. How can I input password inside the txt file commands so that command line plink
command takes it?
Better solution is using Plink's -proxycmd
:
plink -ssh anotherIP -pw passwordForAnotherIP -no-antispoof -proxycmd "plink -ssh hostname@ipaddress -pw password -nc anotherIP:22" -m C:\commands.txt
With the commands.txt
containing only the:
cd /tmp
cat filename
To answer your literal question:
The OpenSSH ssh
has no -pw
switch. See Automatically enter SSH password with script.
Additionally, your command.txt
won't do what you think anyway. It won't run the cd
and cat
within the ssh
. It would run them after the ssh
. So on the ipaddress
. How to do this properly is discussed in: Entering password to remote ssh through Plink after establishing a connection.