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

Use PAM for sshd Motd #831

Merged
Merged
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
11 changes: 8 additions & 3 deletions roles/edpm_sshd/tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,16 @@
{% if edpm_sshd_banner_enabled %}
{% set _ = edpm_sshd_server_options.__setitem__('Banner', '/etc/issue') %}
{% endif %}
{% if edpm_sshd_motd_enabled %}
{% set _ = edpm_sshd_server_options.__setitem__('PrintMotd', 'yes') %}
{% endif %}
{{ edpm_sshd_server_options }}

- name: Set sshd motd when enabled
ansible.builtin.lineinfile:
path: /etc/pam.d/sshd
regexp: "^session.*optional.*pam_motd.so"
line: "session optional pam_motd.so motd=/etc/motd"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, i already have the line in this file in my RHEL 9.2 edpm node, but without the motd=/etc/motd, that is the default, so that part is likely not needed. But, I'm fine either way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, so the issue this solves is that PrintMotd defaults to yes in sshd_config. So if we don't explicitly set it to no then the motd is duplicated.

Explicitly telling pam the exact file to use results in the single message being printed instead of the duplication. But, I did some more digging to make sure I was answering the questions on the BZ accurately, and I actually think that this might be a better solution to the problem:
#838

state: present
when: edpm_sshd_motd_enabled

- name: Adjust ssh server configuration
become: true
ansible.builtin.template:
Expand Down