From 8b88d8fdbeb8a66debd06cce343da17405dc7423 Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Tue, 13 Jun 2023 11:28:15 +0400 Subject: [PATCH] permit root access --- molecule_qemu/playbooks/create.yml | 2 +- molecule_qemu/playbooks/templates/user-data.j2 | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/molecule_qemu/playbooks/create.yml b/molecule_qemu/playbooks/create.yml index e7ffa83..2cdb3b4 100644 --- a/molecule_qemu/playbooks/create.yml +++ b/molecule_qemu/playbooks/create.yml @@ -36,7 +36,7 @@ "image_format": "{{ item.image_format | default(qemu_vm_image_format) }}", "ssh_port": "{{ item.ssh_port | default(22) }}", - "ssh_user": "{{ item.ssh_user }}", + "ssh_user": "{{ item.ssh_user | default('root') }}", "vm_cpus": "{{ item.vm_cpus | default(qemu_vm_cpus) }}", "vm_memory": "{{ item.vm_memory | default(qemu_vm_memory) }}", diff --git a/molecule_qemu/playbooks/templates/user-data.j2 b/molecule_qemu/playbooks/templates/user-data.j2 index eb84d90..ef7ee39 100644 --- a/molecule_qemu/playbooks/templates/user-data.j2 +++ b/molecule_qemu/playbooks/templates/user-data.j2 @@ -4,3 +4,8 @@ ssh_authorized_keys: output: all: ">> /var/log/cloud-init-output.log" + +runcmd: + - sed -i 's/.*\(ssh-.*\)/\1/p' /root/.ssh/authorized_keys + - sed -i 's/^#PermitRootLogin prohibit-password/PermitRootLogin prohibit-password/' /etc/ssh/sshd_config + - systemctl restart ssh