centos下使用shell+expect远程登录主机

# 安装expect
yum install expect

# 新建脚本文件running
#!/usr/bin/expect
spawn /usr/bin/ssh root@114.114.114.114 -p 6666 # 用户名、IP地址、端口号自行设置
expect "password:"
send "remoteComputerPassword\r" # 密码请自行设置
expect efo
interact

# 授权
chmod 755 running

  

posted @ 2019-03-05 19:24  Done、  阅读(672)  评论(0编辑  收藏  举报