Skip to content

Commit

Permalink
Merge pull request #340 from mboisson/centos_authenticationmethods
Browse files Browse the repository at this point in the history
Add authenticationmethods param to local user
  • Loading branch information
cmd-ntrf authored Jun 11, 2024
2 parents 4f0e661 + b406d31 commit f3376b1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@ A `profile::users::local_user` is defined as a dictionary with the following key
| `sudoer` | If enable, the user can sudo without password | Boolean | Yes |
| `selinux_user` | SELinux context for the user | String | Yes |
| `mls_range` | MLS Range for the user | String | Yes |

| `authenticationmethods` | Specifies AuthenticationMethods value for this user in sshd_config | String | Yes |

<details>
<summary>default values</summary>
Expand All @@ -1416,6 +1416,7 @@ profile::users::local::users:
public_keys: "%{alias('terraform.data.public_keys')}"
groups: ['adm', 'wheel', 'systemd-journal']
sudoer: true
authenticationmethods: 'publickey'
```

If `profile::users::local::users` is present in more than one YAML file in the hierarchy,
Expand All @@ -1436,6 +1437,7 @@ profile::users::local::users:
# sudoer: false
# selinux_user: 'unconfined_u'
# mls_range: ''s0-s0:c0.c1023'
# authenticationmethods: 'publickey,password publickey,keyboard-interactive'
```
</details>

Expand Down
1 change: 1 addition & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ profile::users::local::users:
public_keys: "%{alias('terraform.data.public_keys')}"
groups: ['adm', 'wheel', 'systemd-journal']
sudoer: true
authenticationmethods: 'publickey'


profile::freeipa::base::domain_name: "%{alias('terraform.data.domain_name')}"
Expand Down
10 changes: 10 additions & 0 deletions site/profile/manifests/users.pp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
Boolean $sudoer = false,
String $selinux_user = 'unconfined_u',
String $mls_range = 's0-s0:c0.c1023',
String $authenticationmethods = '',
) {
# Configure local account and ssh keys
user { $name:
Expand Down Expand Up @@ -185,4 +186,13 @@
line => "${name} ALL=(ALL) NOPASSWD:ALL",
require => File['/etc/sudoers.d/90-puppet-users'],
}

if $authenticationmethods != '' {
sshd_config { "${name} authenticationmethods":
ensure => present,
condition => "User ${name}",
key => 'AuthenticationMethods',
value => $authenticationmethods
}
}
}

0 comments on commit f3376b1

Please sign in to comment.