Skip to content

Instantly share code, notes, and snippets.

@tenfyzhong
Last active February 1, 2019 06:02
Show Gist options
  • Save tenfyzhong/5ac09babdf9394c7ae2a1bcb4c6dea36 to your computer and use it in GitHub Desktop.
Save tenfyzhong/5ac09babdf9394c7ae2a1bcb4c6dea36 to your computer and use it in GitHub Desktop.
copy ssh public key to machine
#!/usr/bin/expect -f
set timeout 5
set user [lindex $argv 0]
set host [lindex $argv 1]
set password [lindex $argv 2]
spawn ssh-copy-id $user@$host
expect {
"*yes/no" { send "yes\r";exp_continue }
"*password:" { send $password; send "\r" }
"if you think this is a mistake, you may want to use -f option" {exit}
}
expect eof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment