## 修改系统检查项getenforcesetenforce 0## 使用 ssh-keygen 生成证书 私钥 (id_rsa) 与公钥 (id_rsa.pub)ssh-keygen -t rsa#
## 修改系统检查项getenforcesetenforce 0## 使用 ssh-keygen 生成证书 私钥 (id_rsa) 与公钥 (id_rsa.pub)ssh-keygen -t rsa## 如果没有则创建此目录mkdir ~/.ssh## 如果没有则创建此文件touch ~/.ssh/authorized_keys## 将公钥写入授权文件cat id_rsa.pub >> ~/.ssh/authorized_keyscat id_rsa_home_t1.pub >> ~/.ssh/authorized_keys## 添加9010的端口firewall-cmd --zone=public --add-port=9010/tcp --permanentfirewall-cmd --zone=public --add-port=9010/udp --permanent## 删除22端口firewall-cmd --zone=public --remove-port=22/tcp --permanentfirewall-cmd --zone=public --remove-port=22/udp --permanent## 查看已经开放的端口firewall-cmd --list-ports## 重启防火墙firewall-cmd --reloadfirewall-cmd --complete-reload## 编辑SSH配置文件vi /etc/ssh/sshd_config## 修改默认端口,非必要Port 9010## 禁用root账户登录,非必要PermitRootLogin no## 禁用密码登录PasswordAuthentication no## 是否让 sshd 去检查用户家目录或相关档案的权限数据StrictModes no# 是否允许用户自行使用成对的密钥系统进行登入行为,仅针对 version 2。# 至于自制的公钥数据就放置于用户家目录下的 .ssh/authorized_keys 内RSAAuthentication yesPubkeyAuthentication yesAuthorizedKeysFile %h/.ssh/authorized_keys## 重启ssh服务systemctl stop firewalldsystemctl restart sshdsystemctl start firewalld