自动登录远程服务器shell

#!/usr/bin/expect -f
set user username
set host ipaddress
set password pwd
set timeout -1

spawn ssh $user@$host
expect "*assword:*"
send "$password\r"
interact

chmod +x shellname 使脚本生效

把shell所在路径加入环境变量:http://www.cnblogs.com/vontroy/p/5479889.html

在shell中直接使用shellname即可登录远程服务器

 

posted @ 2016-05-10 23:52  fxyburan  阅读(476)  评论(0编辑  收藏  举报