Skip to content

Commit

Permalink
Fix SSH config from cloud-init: rm line about PasswordAuthentication (#…
Browse files Browse the repository at this point in the history
…7518)

* cloud-init: rm line about PasswordAuthentication

Remove the configuration that forbids PasswordAuthentication in Cloud
init ssh file:

[root@bastion sshd_config.d]# cat /etc/ssh/sshd_config.d/50-cloud-init.conf
PasswordAuthentication no

Don't delete the file but use lineinfile module to remove only that
line, as that file may be used for other puprose later.

* Patch rosa config too
  • Loading branch information
fridim authored Dec 14, 2023
1 parent 6b67530 commit 6563fa0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ansible/configs/rosa-consolidated/pre_software.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@
regexp: '^ *PasswordAuthentication'
path: /etc/ssh/sshd_config

- name: Remove 50-cloud-init.conf
- name: Remove PasswordAuthentication line from 50-cloud-init.conf
when: bastion_remove_cloud_init_conf | default(true) | bool
ansible.builtin.file:
state: absent
ansible.builtin.lineinfile:
path: /etc/ssh/sshd_config.d/50-cloud-init.conf
regexp: PasswordAuthentication
state: absent

- name: Restart sshd
ansible.builtin.service:
Expand Down
7 changes: 7 additions & 0 deletions ansible/roles/bastion-student-user/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@
regexp: '^ *PasswordAuthentication'
path: /etc/ssh/sshd_config

- name: Remove PasswordAuthentication line from 50-cloud-init.conf
when: bastion_remove_cloud_init_conf | default(true) | bool
ansible.builtin.lineinfile:
path: /etc/ssh/sshd_config.d/50-cloud-init.conf
regexp: PasswordAuthentication
state: absent

- name: Disable root password authentication
lineinfile:
line: PermitRootLogin without-password
Expand Down

0 comments on commit 6563fa0

Please sign in to comment.