siw36.ansible_ssh_hardening

ansible-ssh-hardening

Ansible 角色 Ansible 质量评分 Ansible 角色

这个角色执行基本的 SSH 加固任务,包括:

  • 更改 SSH 端口
  • 禁用 SSH 密码认证
  • 设置 SELinux 配置
  • 在 firewalld 中允许新的 SSH 端口
  • 安装并配置 fail2ban 以保护 SSH

获取此角色

ansible-galaxy install --roles-path ./roles/ siw36.ansible_ssh_hardening

要求

  • 基于 RHEL 的操作系统(RHEL/CentOS/Fedora)
  • Python 3 作为默认的 Python 解释器
  • 在远程主机上使用的用户必须具有无密码提示的 sudo 命令执行权限。

角色变量

名称 描述 默认值
sshPort 新的 SSH 端口 1337
f2bEnabled 启用 SSH 的 fail2ban true
f2bRetries 允许失败登录的次数 5
f2bBanTime 禁止时间(秒) 3600
f2bIgnoreIP 被忽略的 IP/子网列表 127.0.0.1/32
vmAdmins 应该获得机器访问权限的用户账户和公钥列表 <无 - 可选>
allowedInterfaces SSHD 服务应可用的网络接口列表 <无 - 可选>

示例剧本

playbook.yml

- hosts: servers
  become: true
  roles:
     - siw36.ansible_ssh_hardening

vars/main.yml

vmAdmins:
  - user: siw36
    sshKey: ssh-rsa xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx siw36
allowedInterfaces:
  - eth0

许可证

GNU 通用公共许可证 v3.0

作者信息

由 Robin 'siw36' Klussmann 创建(07/2019)

关于项目

Role to perform basic SSH hardening

安装
ansible-galaxy install siw36.ansible_ssh_hardening
许可证
Unknown
下载
158
拥有者
Platform & DevOps Engineer