My batch file code requires to run some shell commands on multiple servers using SSH. For that I'm using Plink from a for
loop.
I do not want to enter the password in plain text to the Plink command line using -pw
. Instead, due to security concerns, I want to use a password encryption for my password and store the password into a separate text file.
I tried using sshpass
, but that is not supported in batch. As request to run the code will be on multiple servers, so I don't want to generate SSH key pair for each server as it will not be possible for hundreds of servers in the environment.
@echo off
for /f "delims=" %%a in (path\to\servers.txt) DO (
plink -v -ssh user@%%a -pw MY_PASSWORD echo %%a ; cat /path/to/config_file
)
pause
I expect the batch script to run on all servers using encrypted password. But with current code, the output is displayed using plain password.