/etc/ssh/sshd_config ssh服务端配置文件
/etc/ssh/ssh_config ssh客户端配置文件
PermitRootLogin {yes|no} //是否允许root远程登录
PermitRootLogin without-password //仅允许root基于秘钥方式登录
PasswordAuthentication {yes|no} //是否启用密码身份验证,默认开启
PubkeyAuthentication yes 开启公钥认证
PasswordAuthentication no 关闭密码认证
AuthorizedKeysFile .ssh/authorized_keys 公钥存放路径和名称文件
第一步.安装openssh服务
yum -y install openssh*
第二步.更改端口为2222
/etc/ssh/sshd_config
![在这里插入图片描述](https://img-blog.csdnimg.cn/92620061f7f14a449217533fe407cb86.png)
第三步.重启服务
![在这里插入图片描述](https://img-blog.csdnimg.cn/46a5475a26c44be99f0e949f8c416626.png)
第四步.测试
![在这里插入图片描述](https://img-blog.csdnimg.cn/f574a8f2240d4cbfa6daa712ff325d6c.png)
第五步.在client生成公钥秘钥对
![在这里插入图片描述](https://img-blog.csdnimg.cn/bf874f307af0478c9d03a8a16ce2c003.png)
第六步.传送公钥到server
![在这里插入图片描述](https://img-blog.csdnimg.cn/6ff9bd0288944b2a80d92061c0f692b8.png)
第七步.查看
![在这里插入图片描述](https://img-blog.csdnimg.cn/864db6e28d9c421b9dcd0cec966b8df5.png)
第八步.在server开启公钥认证和关闭密码认证。
PubkeyAuthentication yes 开启公钥认证
PasswordAuthentication no 关闭密码认证
第九步.重启服务
![在这里插入图片描述](https://img-blog.csdnimg.cn/55b4fce7c36a411f88598ba5a60d7568.png)
第十步.在client测试
![在这里插入图片描述](https://img-blog.csdnimg.cn/bedbb92d801d4d6e93c2f57d465fc225.png)