参考 Initial Server Setup with CentOS 7
1. 创建非root账户,adduser ,passwd
2. 配置权限,将用户加入wheel用户组 gpasswd -a demo wheel
3. 添加公钥认证
- 在server上使用ssh-keygen生成公私密钥对
- 将公钥保存至~/.ssh/authorized_keys
- 将私钥 id_rsa 复制到管理机,使用XShell登录时,用户验证方式选择“Public Key”,用户密钥选择导入刚刚保存的私钥。
- CentOS中,重启sshd service systemctl restart sshd
- 参考这里
4. 安全设置
- 修改/etc/ssh/sshd_config 文件,修改完后要重启sshd service
PasswordAuthentication no #禁用密码登陆PermitRootLogin no #禁用root login