Last active
February 1, 2019 06:02
-
-
Save tenfyzhong/5ac09babdf9394c7ae2a1bcb4c6dea36 to your computer and use it in GitHub Desktop.
copy ssh public key to machine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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