0

I am using script to loggin my VM2 from VM1 (Password of the VM2: fifa):

for i in {a..z}{a..z}{a..z}{a..z} 

do

# $i as a password

ssh root@ipaddress 

read i

echo $i

done

bit it doesn't work. It always ask me to enter the password. How can I make it to enter password automatically?

  • If any of the existing answers solved your problem, please consider accepting it by clicking on the checkmark next to it. Thank you! – Jeff Schaller Jun 11 '17 at 12:18
0

It's asking you to enter "the password" because of the read i statement, which is clobbering your for loop variable. I believe the ssh client tries to read from the tty; I'm not aware of a direct way to pass a password to ssh. Alternatives include sshpass and expect. See SSH login with clear text password as a parameter? and https://stackoverflow.com/questions/233217/pass-password-to-su-sudo-ssh and https://stackoverflow.com/questions/12118308/command-line-to-execute-ssh-with-password-authentication

|improve this answer|||||

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.