2

The ssh from server0 to (server1,server2,server3) (no password need to SSH (trust exists between all servers and private key exists on all servers)) but a remote script on server (server1,server2 & server3 ) which starts a service/application needs a password for it to start. I want to be able to use ssh and run a command automatically on remote server. The remote script needs a password or expects a password answer with a password

ssh -n -o StrictHostKeyChecking=no  servername remotescrip

Enter application password to run the script:

4

Then use expect:

expect -c 'spawn ssh serversuser@server' \
-c 'expect "serverprompt" {send /path/to/your/script\n}' \
-c 'expect "Enter application password to run the script:" {send yourpassword\n}'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.