0

Why when using sshpass in a loop the first sshpass executes commands, while the next does not for element in "${a[@]}" do { echo "$element" sshpass -p "omg" ssh root@$element 'ls' } done

P.S found a fix:

for element in "${a[@]}" do { echo "$element"; export SSHPASS='omg' ;sshpass -e ssh -o StrictHostKeyChecking=no root@$element 'ls' unset SSHPASS

} done`

New contributor
Goking is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • Can we have some context, like for instance what a is? – var firstName Jan 11 at 18:26
  • a is an array with containing ip's of VM's – Goking Jan 11 at 18:32
  • fixed it use: echo "$element"; export SSHPASS='omg' ;sshpass -e ssh -o StrictHostKeyChecking=no root@$element 'ls' unset SSHPASS – Goking Jan 11 at 18:42
  • Do not add additional information in the comment section. Better edit your question with the new information. – zx485 Jan 11 at 18:44
  • @Goking make an answer to this question and mark it as the solution. Remove the fixed code sample from the question and place it in the solution. – var firstName Jan 11 at 19:32
0

P.S found a fix:

for element in "${a[@]}" do { echo "$element"; export SSHPASS='omg' ;sshpass -e ssh -o StrictHostKeyChecking=no root@$element 'ls' unset SSHPASS

} done

New contributor
Goking is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

Goking is a new contributor. Be nice, and check out our Code of Conduct.

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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