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 name: root
password: "{{ ssh_password | password_hash('sha512') }}" 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 # config sshd_config file , no root password
- name: change sshd_config to no root password #- name: change sshd_config to no root password
lineinfile: # lineinfile:
path: "{{ path_sshd_config_file }}" # path: "{{ path_sshd_config_file }}"
regexp: "PermitRootLogin yes" # regexp: "PermitRootLogin yes"
line: "#PermitRootLogin prohibit-password" # line: "#PermitRootLogin prohibit-password"
state: present # state: present
notify: Restart ssh service # notify: Restart ssh service
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# service should start on boot. # service should start on boot.
- name: service should start on boot - name: service should start on boot

View File

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