without sshd_config and delete authorized_keys

This commit is contained in:
Ruben Blanco 2023-10-26 12:59:31 +02:00
parent b997fc5d01
commit a4623e0bd5
2 changed files with 13 additions and 8 deletions

View File

@ -18,16 +18,20 @@
name: root
password: "{{ ssh_password | password_hash('sha512') }}"
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# delete root ssh pub key in Authorized_keys
- name: delete ssh pub key in /root/.ssh/authorized_keys
file:
path: "{{ root_authorized_keys }}"
state: absent
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# config sshd_config file , no root password
- name: change sshd_config to no root password
lineinfile:
path: "{{ path_sshd_config_file }}"
regexp: "PermitRootLogin yes"
line: "#PermitRootLogin prohibit-password"
state: present
notify: Restart ssh service
#- name: change sshd_config to no root password
# lineinfile:
# path: "{{ path_sshd_config_file }}"
# regexp: "PermitRootLogin yes"
# line: "#PermitRootLogin prohibit-password"
# state: present
# notify: Restart ssh service
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# service should start on boot.
- name: service should start on boot

View File

@ -2,6 +2,7 @@
ssh_daemon: ssh
path_sshd_config_file: /etc/ssh/sshd_config
path_bashrc_root: /root/.bashrc
root_authorized_keys: /root/.ssh/authorized_keys
export_LS_OPTIONS: export LS_OPTIONS='--color=auto'
eval_dircolors: eval "$(dircolors)"
alias_ls: alias ls='ls $LS_OPTIONS'