Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if authenticationmethods is specified for a local user, configure an sshd exception #340

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,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 @@ -1326,6 +1326,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 @@ -1346,5 +1347,6 @@ profile::users::local::users:
# sudoer: false
# selinux_user: 'unconfined_u'
# mls_range: ''s0-s0:c0.c1023'
# authenticationmethods: 'publickey,password publickey,keyboard-interactive'
```
</details>
1 change: 1 addition & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,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 @@ -171,4 +172,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
}
}
}
Loading