SSH免密配置

1. 在三个节点生成秘钥
cd ~/.ssh
ssh-keygen -t rsa

2.合并三个节点的密码
cat id_rsa.pub >> authorized_keys
ssh postgres@test-postgre-sql-2 cat ~/.ssh/id_rsa.pub>> authorized_keys
ssh postgres@test-postgre-sql-3 cat ~/.ssh/id_rsa.pub>> authorized_keys

3 分发authorized_keys和known_hosts到三个节点
scp authorized_keys postgres@test-postgre-sql-2:/home/postgres/.ssh/.
scp known_hosts postgres@test-postgre-sql-2:/home/postgres/.ssh/.

scp authorized_keys postgres@test-postgre-sql-3:/home/postgres/.ssh/.
scp known_hosts postgres@test-postgre-sql-3:/home/postgres/.ssh/.

4. 设置权限
chmod 700 ~/.ssh/
chmod 600 authorized_keys

5.SSH登录过程如果出现问题可查看安全日志
/var/log/secure

常见问题
Jan 18 18:12:00 test-postgre-sql-2 sshd[12378]: Authentication refused: bad ownership or modes for file /home/postgres/.ssh/authorized_keys

posted @ 2020-01-18 18:17  TraderLee  阅读(144)  评论(0编辑  收藏  举报