Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #script.sh
- #!/usr/bin/expect -f
- username=user
- password=pass
- for HOST in $(cat $1)
- do
- echo "ssh $username@$HOST"
- expect "Password:"
- send "$passr"
- done
- file.txt
- 1.1.1.1
- 2.2.2.2
- 3.3.3.3
- 4.4.4.4
- # vim server.list
- 192.168.0.100
- 192.168.0.101
- # apt-get install sshpass
- $ vim script.sh
- #!/bin/bash
- while read -r line
- do
- echo "running $line"
- sshpass -p PASSWORD ssh-copy-id USERNAME@$line -o "StrictHostKeyChecking no"
- done < "server.list"
- $ sh script.sh
- running 192.168.0.100
- ...
- Number of key(s) added: 1
- running 192.168.0.101
- ...
- Number of key(s) added: 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement