Skip to content
This repository was archived by the owner on Dec 26, 2020. It is now read-only.

Commit c391a0c

Browse files
authored
Merge pull request #195 from dev-sec/fix_190
parameterize PermitRootLogin
2 parents cff51e1 + 8a6aa66 commit c391a0c

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Warning: This role disables root-login on the target server! Please make sure yo
2626
|`ssh_client_alive_count` | 3 | defines how often keep-alive messages are sent |
2727
|`ssh_permit_tunnel` | false | true if SSH Port Tunneling is required |
2828
|`ssh_remote_hosts` | [] | one or more hosts and their custom options for the ssh-client. Default is empty. See examples in `defaults/main.yml`.|
29-
|`ssh_allow_root_with_key` | false | false to disable root login altogether. Set to true to allow root to login via key-based mechanism.|
29+
|`ssh_permit_root_login` | no | Disable root-login. Set to `without-password` or `yes` to enable root-login |
3030
|`ssh_allow_tcp_forwarding` | false | false to disable TCP Forwarding. Set to true to allow TCP Forwarding.|
3131
|`ssh_gateway_ports` | `false` | `false` to disable binding forwarded ports to non-loopback addresses. Set to `true` to force binding on wildcard address. Set to `clientspecified` to allow the client to specify which address to bind to.|
3232
|`ssh_allow_agent_forwarding` | false | false to disable Agent Forwarding. Set to true to allow Agent Forwarding.|

defaults/main.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ ssh_permit_tunnel: false
4848
# options: ['StrictHostKeyChecking no']
4949
ssh_remote_hosts: []
5050

51-
# false to disable root login altogether. Set to true to allow root to login via key-based mechanism.
52-
ssh_allow_root_with_key: false # sshd
51+
# Set this to "without-password" or "yes" to allow root to login
52+
ssh_permit_root_login: 'no' # sshd
5353

5454
# false to disable TCP Forwarding. Set to true to allow TCP Forwarding.
5555
ssh_allow_tcp_forwarding: false # sshd

templates/opensshd.conf.j2

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
# Basic configuration
77
# ===================
88

9-
# Either disable or only allowssh root login via certificates.
10-
PermitRootLogin {{ 'without-password' if (ssh_allow_root_with_key|bool) else 'no' }}
9+
# Either disable or only allow root login via certificates.
10+
PermitRootLogin {{ ssh_permit_root_login }}
1111

1212
# Define which port sshd should listen to. Default to `22`.
1313
{% for port in ssh_server_ports -%}

tests/default_custom.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
- ansible-ssh-hardening
2222
vars:
2323
network_ipv6_enable: true
24-
ssh_allow_root_with_key: true
2524
ssh_allow_tcp_forwarding: true
2625
ssh_gateway_ports: true
2726
ssh_allow_agent_forwarding: true
@@ -37,6 +36,7 @@
3736
ssh_deny_groups: 'foo bar'
3837
ssh_authorized_keys_file: '/etc/ssh/authorized_keys/%u'
3938
ssh_max_auth_retries: 10
39+
ssh_permit_root_login: "without-password"
4040
ssh_permit_tunnel: true
4141
ssh_print_motd: true
4242
ssh_print_last_log: true

0 commit comments

Comments
 (0)