linux设置ssh无密访问

linux设置ssh无密访问

# hadoop01操作
# 生成密钥
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
# 添加密钥到认证库中
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
# hadoop02操作
# 生成密钥
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
# hadoop03操作
# 生成密钥
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
# 将每一个主机的公钥都添加到hadoop01的认证库中
# hadoop02操作
cp ~/.ssh/id_rsa.pub ~/.ssh/id_rsa.pub.hadoop02
scp ~/.ssh/id_rsa.pub.hadoop02 hadoop01:$PWD  # 发送到hadoop01

# hadoop03操作
cp ~/.ssh/id_rsa.pub ~/.ssh/id_rsa.pub.hadoop03
scp ~/.ssh/id_rsa.pub.hadoop03 hadoop01:$PWD  # 发送到hadoop01

# hadoop01操作,添加hadoop02,hadoop03公钥到认证库中
cat ~/.ssh/id_rsa.pub.hadoop02 >> ~/.ssh/authorized_keys
cat ~/.ssh/id_rsa.pub.hadoop03 >> ~/.ssh/authorized_keys
# hadoop01操作,将认证库发送到hadoop02,hadoop03
scp ~/.ssh/authorized_keys hadoop02:$PWD
scp ~/.ssh/authorized_keys hadoop03:$PWD

你可能感兴趣的:(linux设置ssh无密访问)