I have local shell script. Now, I want to run this local script in remote machine. Of course I can use ssh
, but as it(the local shell script) should be like an automated one, it shouldn't ask for password to enter manually. So I used expect to eliminate that problem, so that if I run the script it wont ask password. And my script looks like below.
#!/usr/bin/expect
spawn ssh -o GSSAPIAuthentication=no root@10.3.0.39 'bash -s' < /path/to/localscript
expect -timeout 7 "*(yes/no)?" { send "yes\r";exp_continue }
expect -timeout 3 "*d: "
send "qbcrootpass\n"
interact
But it is not working. Please note, in my scenario, I don't want to use public key authentication.
Please help me to execute a local script in a remote machine using using expect.
No comments:
Post a Comment