#!/bin/bash
# 用户名为所有主机用户名,用户密码同理,$1为位置变量值(ip)
ip=$1
expect -c "
set timeout 1;
spawn ssh 用户名@${ip};
expect {
*yes/no* { send \"yes\r\"; exp_continue }
*password:* { send \"用户密码\r\" }
}
interact
"
#!/bin/bash
# 用户名为所有主机用户名,用户密码同理,$1为位置变量值(ip)
ip=$1
expect -c "
set timeout 1;
spawn ssh 用户名@${ip};
expect {
*yes/no* { send \"yes\r\"; exp_continue }
*password:* { send \"用户密码\r\" }
}
interact
"