linux在终端免密码输入自动登录远程服务器脚本

1. 安装expect:sudo apt-get install expect

2. vim login.sh 输入以下脚本内容:

#!/usr/bin/expect

set user ming***** #用户名

set ipaddress 10.255.****** #IP地址

set passwd ********* #密码

set timeout 30

spawn ssh $user@$ipaddress

expect {

    "*password:" { send "$passwd\r" }

    "yes/no" { send "yes\r";exp_continue }

}

interact

3. 使用方法:expect login.sh

猜你喜欢

转载自blog.csdn.net/u010397980/article/details/82078319