[Ilugc] SSH - Command

  • From: girishvenkatachalam@xxxxxxxxx (Girish Venkatachalam)
  • Date: Sat, 16 Apr 2011 07:33:25 +0530

On Sat, Apr 16, 2011 at 3:53 AM, Ashish Verma <ilugid at gmail.com> wrote:

Hi,

I am executing the below ssh command. It requires to run a specific script
on the remote host with sudo su. However the first prompt for password comes
by fine, however it automatically accepts some value for the second prompt,
i.e. for the sudo prompt.

$cat hostlist | while read hostnam; do ssh ashish@$hostnam sudo su -c
./comm1; done
ashish at 10.21.102.32's password:
Password:
Sorry, try again.
Password:
Sorry, try again.
Password:
Sorry, try again.
sudo: 3 incorrect password attempts


How do I make it to wait for my input? Moreover if I run just the command,
i.e. without the while loop it runs fine.


Answer is simple. Do passwordless public key login with ssh.

And you should never have password prompts in shell scripts unless
 you are setting a password or it is an interactive script.

-Girish


-- 
G3 Tech
Networking appliance company
web: http://g3tech.in ?mail: girish at g3tech.in

Other related posts: