shell初始化服务器[一]
#!/usr/bin/expect set timeout 10 set username [lindex $argv 0] set password [lindex $argv 1] set hostname [lindex $argv 2] spawn ssh-copy-id -i /root/.ssh/id_rsa.pub $username@$hostname expect { "Are you sure you want to continue connecting" { send "yes\r" expect "password:" send "$password\r" } "install the new keys" { send "yes\r" expect "password:" send "$password\r" } "password:" { send "$password\r" } "Now try loggin into the machine" { } } expect eof

浙公网安备 33010602011771号