Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #script.sh
  2. #!/usr/bin/expect -f
  3. username=user
  4. password=pass
  5. for HOST in $(cat $1)
  6. do
  7. echo "ssh $username@$HOST"
  8. expect "Password:"
  9. send "$passr"
  10. done
  11.  
  12. file.txt
  13. 1.1.1.1
  14. 2.2.2.2
  15. 3.3.3.3
  16. 4.4.4.4
  17.  
  18. # vim server.list
  19. 192.168.0.100
  20. 192.168.0.101
  21.  
  22. # apt-get install sshpass
  23. $ vim script.sh
  24. #!/bin/bash
  25. while read -r line
  26. do
  27. echo "running $line"
  28. sshpass -p PASSWORD ssh-copy-id USERNAME@$line -o "StrictHostKeyChecking no"
  29. done < "server.list"
  30.  
  31. $ sh script.sh
  32. running 192.168.0.100
  33. ...
  34. Number of key(s) added: 1
  35. running 192.168.0.101
  36. ...
  37. Number of key(s) added: 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement