Skip to content

Instantly share code, notes, and snippets.

@eran132
Last active August 29, 2015 14:06
Show Gist options
  • Save eran132/2ce8bb567e317e51b2e6 to your computer and use it in GitHub Desktop.
Save eran132/2ce8bb567e317e51b2e6 to your computer and use it in GitHub Desktop.
Set single sign-on to SSH servers
#First make sure you have expect package installed
#Prepare the ip addresses list using NMAP
#!/usr/bin/expect
set hostlist [open /path/to/ip_addresses_of_hosts_with_ssh_daemon.txt]
set ipaddrs [read $hostlist]
foreach line [split $ipaddrs \n] {
spawn ssh-copy-id user@$line
set pass "password"
expect {
"yes/no" {send "yes\r"}
password: {send "$pass\r"; exp_continue}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment