elnappo.secure_openssh_server
ansible-role-secure-openssh-server
设置 OpenSSH 服务器(版本 >= 6.5)的安全配置。该剧本会扩展你的 sshd 配置文件,而不是替代它。
- 禁用 SSH 版本 1
- 禁用 RSA 身份验证(仅适用于版本 1)
- 不允许空密码
- 仅允许没有密码的 root 登录
- 使用严格模式
- 只允许 安全安全外壳 推荐的 KexAlgorithms、Ciphers 和 MACs
- 默认删除 DSA 和 ECDSA 主机密钥。如果不想这么做,请更改
ssh_remove_deprecated_server_keys
- 如果 RSA 主机密钥小于 4096 位(默认),将其重新生成
- 默认禁用密码登录,这还设置了
MaxAuthTries 1
和LoginGraceTime 30
推荐的 ~/.ssh/config
和 /etc/ssh/ssh_config
Host *
HashKnownHosts yes
PasswordAuthentication no
PubkeyAuthentication yes
ChallengeResponseAuthentication no
HostKeyAlgorithms ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-ed25519,ssh-rsa,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256
KexAlgorithms curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-ripemd160-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-ripemd160,umac-128@openssh.com
旧版连接的别名:alias ssh_ignore="ssh -F /dev/null"
灵感来源
需求
- Ubuntu 或 Debian
- OpenSSH 服务器 >= 6.5(在 Ubuntu >= 14.04 和 Debian >= 8 中可用)
角色变量
ssh_sshd_config_dir: /etc/ssh/
ssh_sshd_config_path: "{{ ssh_sshd_config_dir }}sshd_config"
ssh_permit_root_login: "without-password"
(引号是必需的!)ssh_disable_password_login: true
ssh_remove_deprecated_server_keys: true
(禁用 DSA、ECDSA,并在小于ssh_host_rsa_key_length
时重新生成 RSA 密钥)ssh_host_rsa_key_length: 4096
ssh_setup_ufw: true
ssh_port: 22
依赖
无。
示例剧本
- hosts: server
remote_user: root
vars:
- ssh_remove_deprecated_server_keys: false
- ssh_port: 1813
roles:
- { role: elnappo.secure_openssh_server }
许可证
MIT
作者信息
elnappo elnappo@nerdpol.io
安装
ansible-galaxy install elnappo.secure_openssh_server
许可证
Unknown
下载
80
拥有者