shell脚本
1、首先安装expect,执行如下命令
yum install expect
2、新建shell文件ssh.sh
vi ssh.sh
复制以下内容
#!/usr/bin/expect set user "root" #账号 set password "<your-password>" #密码 spawn ssh $user@<ssh-server-ip> #服务器 expect "*password:" send "$password\r" expect "*#" interact
3、每次登录运行该脚本
sh ssh.sh