From fd8012ce637fb5446a4a6cf7e9ed1bcdbe8bfeb8 Mon Sep 17 00:00:00 2001 From: karpenok Date: Sun, 8 Nov 2026 12:16:52 +0700 Subject: [PATCH] =?UTF-8?q?fix(ssh):=20=D0=BE=D1=82=D0=BA=D0=BB=D1=8E?= =?UTF-8?q?=D1=87=D0=B8=D1=82=D1=8C=20=D0=BF=D0=B0=D1=80=D0=BE=D0=BB=D0=B8?= =?UTF-8?q?=20=D1=87=D0=B5=D1=80=D0=B5=D0=B7=2000-disable-passwords.conf,?= =?UTF-8?q?=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B8=D1=82=D1=8C=20=D0=B2=D1=80?= =?UTF-8?q?=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD=D1=8B=D0=B9=20=D0=BF=D0=B0=D1=80?= =?UTF-8?q?=D0=BE=D0=BB=D1=8C=20=D0=B8=D0=B7=20hosts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inventories/prod/hosts.yml | 1 - roles/host/defaults/main.yml | 1 + roles/host/handlers/main.yml | 1 + roles/host/tasks/main.yml | 14 +++++++++++++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/inventories/prod/hosts.yml b/inventories/prod/hosts.yml index af22a71..8f03614 100644 --- a/inventories/prod/hosts.yml +++ b/inventories/prod/hosts.yml @@ -7,7 +7,6 @@ all: rus-central: ansible_host: 45.154.185.208 ansible_user: root - ansible_password: "rJ1vC5cS5gxA" netbird: hosts: rus-central: diff --git a/roles/host/defaults/main.yml b/roles/host/defaults/main.yml index 604464a..3c73929 100644 --- a/roles/host/defaults/main.yml +++ b/roles/host/defaults/main.yml @@ -2,3 +2,4 @@ host_authorized_keys: - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIF/yxhAs022l/8FlPlhyi7NeF3CvVGsev3B1HtKICO7M root_from_windows" - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICf80si9YG5lZkhRkVZUclrxu6hEGimWrAH/uib10rdi gitea@gitea" + diff --git a/roles/host/handlers/main.yml b/roles/host/handlers/main.yml index 7f76425..2a60def 100644 --- a/roles/host/handlers/main.yml +++ b/roles/host/handlers/main.yml @@ -3,3 +3,4 @@ ansible.builtin.service: name: ssh state: reloaded + diff --git a/roles/host/tasks/main.yml b/roles/host/tasks/main.yml index e0cf861..eed2c6a 100644 --- a/roles/host/tasks/main.yml +++ b/roles/host/tasks/main.yml @@ -25,9 +25,15 @@ mode: "0600" loop: "{{ host_authorized_keys }}" +- name: Удалить cloud-init настройки пароля SSH + ansible.builtin.file: + path: /etc/ssh/sshd_config.d/50-cloud-init.conf + state: absent + notify: Перезапустить SSH + - name: Отключить вход по паролю в drop-in sshd_config.d ansible.builtin.copy: - dest: /etc/ssh/sshd_config.d/99-disable-passwords.conf + dest: /etc/ssh/sshd_config.d/00-disable-passwords.conf content: | PasswordAuthentication no KbdInteractiveAuthentication no @@ -36,6 +42,12 @@ mode: "0644" notify: Перезапустить SSH +- name: Удалить устаревший drop-in sshd_config.d + ansible.builtin.file: + path: /etc/ssh/sshd_config.d/99-disable-passwords.conf + state: absent + notify: Перезапустить SSH + - name: Запретить PasswordAuthentication в основном sshd_config ansible.builtin.lineinfile: path: /etc/ssh/sshd_config