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

[ssh_hardening] AllowUsers passing user with brackets #838

Open
Dan-Sun opened this issue Jan 9, 2025 · 1 comment
Open

[ssh_hardening] AllowUsers passing user with brackets #838

Dan-Sun opened this issue Jan 9, 2025 · 1 comment
Assignees
Labels

Comments

@Dan-Sun
Copy link

Dan-Sun commented Jan 9, 2025

Description

I use the the variable ssh_allow_users for a debian system:

ssh_allow_users: 
      - "{{ ansible_user }}"
      - user2
      - user3

The outcome is AllowUsers ['user1', 'user2', 'user3'] which doesn't work on my end.
It would work like AllowUsers user1 user2 user3.

Reproduction steps

Add the variable:

ssh_allow_users: 
      - "{{ ansible_user }}"
      - user2
      - user3


### Current Behavior

The out come is `AllowUsers ['user1', 'user2', 'user3']` which doesn't work on my side.

### Expected Behavior

It would work like `AllowUsers user1 user2 user3`.

### OS / Environment

The target is a fresh installed Debian minimal system. Coming from an Arch system.

### Ansible Version

```Shell
2.18.1

Collection Version

10.2.0

Additional information

...

@Dan-Sun Dan-Sun added the bug label Jan 9, 2025
@schurzi schurzi self-assigned this Jan 13, 2025
@schurzi
Copy link
Contributor

schurzi commented Jan 13, 2025

Thanks for the report.

We documented that parameter as string, so a list is not expected here.

  • ssh_allow_users
    • Default: ``
    • Description: if specified, login is allowed only for user names that match one of the patterns.
    • Type: str

To fix your problem, you need to convert the list to a string in your vars. e.g.:

ssh_allow_users: "{{ ansible_user }} user2 user3"

Your use-case seems reasonable though. Let me think a bit on how to support that, this might be a good addition to our collection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants