Centos7 多节点 root SSH无秘钥设置
网络拓扑
计算机名称 IP地址 角色
centos7-01 192.168.18.128 Master Server
centos7-02 192.168.18.129 compute1
centos7-03 192.168.18.130 compute2
\etc\ssh\sshd_config 配置文件如果:
Protocol 2
ChallengeResponseAuthentication no
GSSAPIAuthentication no
GSSAPICleanupCredentials yes
UsePAM yes
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS
X11Forwarding yes
Subsystem sftp /usr/libexec/openssh/sftp-server
UseDNS no
ClientAliveInterval 30
ClientAliveCountMax 5
AddressFamily inet
PermitRootLogin yes
SyslogFacility AUTHPRIV
PasswordAuthentication yes
ssh无密钥登陆
集群节点,执行命令
#ssh-keygen -t rsa
master节点 进入/root/.ssh目录,把公钥导入到认证文件
#cd /root/.ssh
#cat id_rsa.pub>> authorized_keys
master节点 执行把另外两台机器公钥导入到认证文件
#ssh root@192.168.18.129 cat ~/.ssh/id_rsa.pub>> authorized_keys
#ssh root@192.168.18.130 cat ~/.ssh/id_rsa.pub>> authorized_keys
master节点 执行把authorized_keys远程copy到另外两台机器
#scp authorized_keys 192.168.18.129:/root/.ssh/
#scp authorized_keys 192.168.18.130:/root/.ssh/
集群节点更改相关文件的权限
#chmod 700 ~/.ssh
#chmod 600 ~/.ssh/authorized_keys
集群节点重启服务
#systemctl restart sshd
完成免密码登录设置,测试
#ssh centos7-03