集群之间相互通讯很多时候需要免密配置,免密脚本可以帮助我们更方便的建立免密
现配置 hadoop用户免密 /opt/sys_hbase/host_ip 配置如下
sshConfig.sh 脚本如下
#! /bin/bash
function sshFreeLogin()
{
#1.检测expect服务是否存在,不存在则使用yum安装expect
expectIsExists=`rpm -qa | grep expect`
if [ -z $expectIsExists ]
then
yum -y install expect
fi
# user=$(whoami)
# user=$(env | grep USER | cut -d "=" -f 2)
# if [ "$user" -eq "root" ]
#2.密钥对不存在则创建密钥
[ ! -f /home/hadoop/.ssh/id_rsa.pub ] && ssh-keygen -t rsa -P "" -f /home/hadoop/.ssh/id_rsa
while read line;do
#提取文件中的ip
hostname=`echo $line | cut -d " " -f2`
#提取文件中的用户名
user_name=`echo