Skip to content

Commit

Permalink
Make changes portable
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Schurz <[email protected]>
  • Loading branch information
schurzi committed Dec 22, 2024
1 parent 329e0ba commit a7b4cf3
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions molecule/os_hardening/verify_tasks/ssh_auth_locked.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
ansible.builtin.service:
name: sshd
state: started
ignore_errors: true

- name: Start ssh service
ansible.builtin.service:
name: ssh
state: started
ignore_errors: true

- name: Set password for test
ansible.builtin.set_fact:
Expand All @@ -37,19 +44,19 @@

- name: Check successful login with password
ansible.builtin.shell:
cmd: sshpass -p {{ test_pw }} ssh locked_user@localhost echo "success"
cmd: sshpass -p {{ test_pw }} ssh -o StrictHostKeyChecking=no locked_user@localhost echo "success"

- name: Check successful login with ssh key
ansible.builtin.shell:
cmd: ssh -i /root/locked_user_id locked_user@localhost echo "success"
cmd: ssh -i /root/locked_user_id -o StrictHostKeyChecking=no locked_user@localhost echo "success"

- name: Set password change date for locked_user
ansible.builtin.shell:
cmd: chage -d 2020-01-01 locked_user

- name: Check unsuccessful login with password
ansible.builtin.shell:
cmd: sshpass -p {{ test_pw }} ssh locked_user@localhost echo "success"
cmd: sshpass -p {{ test_pw }} ssh -o StrictHostKeyChecking=no locked_user@localhost echo "success"
register: output
ignore_errors: true

Expand All @@ -62,4 +69,4 @@

- name: Check successful login with ssh key
ansible.builtin.shell:
cmd: ssh -i /root/locked_user_id locked_user@localhost echo "success"
cmd: ssh -i /root/locked_user_id -o StrictHostKeyChecking=no locked_user@localhost echo "success"

0 comments on commit a7b4cf3

Please sign in to comment.