From 8c2e542b20c60083fff0e36cae8c89d87ecccea8 Mon Sep 17 00:00:00 2001 From: Caleb Connolly Date: Tue, 28 Feb 2023 21:29:57 +0000 Subject: [PATCH] test/test_qemu: use ssh key auth instead of password --- test/test_qemu_running_processes.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/test_qemu_running_processes.py b/test/test_qemu_running_processes.py index b37beae1..c654cbec 100644 --- a/test/test_qemu_running_processes.py +++ b/test/test_qemu_running_processes.py @@ -75,14 +75,19 @@ class QEMU(object): pmbootstrap_run(args, config, ["config", "kernel", "virt"]) pmbootstrap_run(args, config, ["config", "extra_packages", "none"]) pmbootstrap_run(args, config, ["config", "user", "testuser"]) + pmbootstrap_run(args, config, ["config", "ssh_key_glob", "~/.local/var/pmbootstrap/chroot_native/home/pmos/ssh_id_ed25519.pub"]) pmbootstrap_run(args, config, ["config", "ui", ui]) # Prepare native chroot pmbootstrap_run(args, config, ["-y", "zap"]) - pmb.chroot.apk.install(args, ["openssh-client", "sshpass"]) + pmb.chroot.apk.install(args, ["openssh-client"]) + pmb.chroot.user(args, ["ssh-keygen", "-t", "ed25519", "-f", "/home/pmos/.ssh/id_ed25519", "-N", "",]) + # Make sure the host can see the pubkey + pmb.chroot.user(args, ["cp", "/home/pmos/.ssh/id_ed25519.pub", "/home/pmos/ssh_id_ed25519.pub"]) + pmb.chroot.user(args, ["chmod", "644", "/home/pmos/ssh_id_ed25519.pub"]) # Create and run rootfs - pmbootstrap_yes(args, config, ["install"]) + pmbootstrap_yes(args, config, ["install", "--password", "y"]) self.process = pmbootstrap_run(args, config, ["qemu", "--display", "none"], "background") @@ -99,7 +104,7 @@ def ssh_run(args, command): :param command: flat string of the command to execute, e.g. "ps au" :returns: the result from the SSH server """ - ret = pmb.chroot.user(args, ["sshpass", "-py", "ssh", + ret = pmb.chroot.user(args, ["ssh", "-o", "ConnectTimeout=10", "-o", "UserKnownHostsFile=/dev/null", "-o", "StrictHostKeyChecking=no", -- 2.45.2