Search code examples
batch-fileputty

Batch file to auto login in PuTTY and and run a specific command


I am using this command to direct login in SSH.

"C:\Program Files\PuTTY\putty.exe" -ssh msnoc@10.0.0.11 -pw mypassword -P pwd

But after login i want to run a command every time

sh isdn st | i Bs

Right now I am handling 20 server and its too time taking to login every server and putting the same command.

How do I create a batch file to automate auto login and running the above mentioned command?


Solution

  • You can use below command :

    C:\Program Files\PuTTY\putty.exe" -ssh msnoc@10.0.0.11 -pw mypassword -P pwd -M "C:\Program Files\PuTTY\script.txt
    

    where script.txt contain your commands:

    sh isdn st | i Bs