应用shell (ssh)远程链接主机

1.先用ssh root@192.168.88.132 连接主机,后退出。

2.然后运行脚本 rj.sh

/usr/bin/expect <<EOF
set timeout 30
spawn ssh -l root 192.168.88.132  "useradd lilei"
expect "password:"
send "123\r:"
spawn ssh -l root 192.168.88.132 "yum install nmap -y"
expect "password:"
send "123\r:"
expect eof
EOF
useradd lilei
~                                                                        

 

posted on 2019-06-25 18:54  北橘  阅读(774)  评论(0编辑  收藏  举报