[root@database2 ~]# cat ssh.sh if [ ! $# -eq 2 ] ;thenecho "请输入用户密码以空格分开"exitelsessh-keygen -t rsa#用户名uname="$1"#密码passwd="$2"fi#执行检测并安装expect模块ep=`rpm -qa | grep expect` if [ -z $ep ] ; then echo "检测到你的系统,没有安装expect模块,准备执行安装" sleep 2 yum install -y expectelse echo "已经安装expect模块,3秒后,开始执行ssh文件同步" sleep 3fi#公钥无ssh认证模块cat hosts | while read hostdoecho "当前正在向$host上传输ssh文件"expect <