From a5fd8fd512d65b7a73c9d5ddd5e85d780c5dea5d Mon Sep 17 00:00:00 2001 From: Rin Date: Sat, 4 May 2024 11:37:52 +0800 Subject: [PATCH] z --- dist/index.js | 10 +++++++--- index.js | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/dist/index.js b/dist/index.js index 1d342b0..d587c0a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -31133,11 +31133,15 @@ function setup_sshkey(pubkey, qemu_process, ready_callback) { let waitForKey = waitFor(pubkeyContent, () => { ready_callback(qemu_process) }) - qemu_process.stdout.on('data', waitForKey) - qemu_process.stdin.write("echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config\n"); - qemu_process.stdin.write("/etc/rc.d/sshd restart\n"); + qemu_process.stdout.on('data', data => { + process.stdout.write(data.toString()) + waitForKey(data) + }) + qemu_process.stdin.write(`echo "${pubkeyContent}" > /root/.ssh/authorized_keys\n`); qemu_process.stdin.write(`cat /root/.ssh/authorized_keys\n`); + qemu_process.stdin.write("echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config\n"); + qemu_process.stdin.write("/etc/rc.d/sshd restart\n"); }) qemu_process.stdout.on('data', (data) => { waitForPrompt(data) diff --git a/index.js b/index.js index 602cfb9..e073972 100644 --- a/index.js +++ b/index.js @@ -243,11 +243,15 @@ function setup_sshkey(pubkey, qemu_process, ready_callback) { let waitForKey = waitFor(pubkeyContent, () => { ready_callback(qemu_process) }) - qemu_process.stdout.on('data', waitForKey) - qemu_process.stdin.write("echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config\n"); - qemu_process.stdin.write("/etc/rc.d/sshd restart\n"); + qemu_process.stdout.on('data', data => { + process.stdout.write(data.toString()) + waitForKey(data) + }) + qemu_process.stdin.write(`echo "${pubkeyContent}" > /root/.ssh/authorized_keys\n`); qemu_process.stdin.write(`cat /root/.ssh/authorized_keys\n`); + qemu_process.stdin.write("echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config\n"); + qemu_process.stdin.write("/etc/rc.d/sshd restart\n"); }) qemu_process.stdout.on('data', (data) => { waitForPrompt(data)