From 47d331b6646d7591a7fadd2304637ad77b88c359 Mon Sep 17 00:00:00 2001 From: Floris Bos Date: Mon, 20 Dec 2021 21:46:37 +0100 Subject: [PATCH] Allow multi-line authorized_keys Closes #316 --- OptionsPopup.qml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/OptionsPopup.qml b/OptionsPopup.qml index 781568e..1899dfc 100644 --- a/OptionsPopup.qml +++ b/OptionsPopup.qml @@ -603,16 +603,23 @@ Popup { addCloudInit("ssh_pwauth: true") } if (radioPubKeyAuthentication.checked) { - var pubkey = fieldPublicKey.text.replace(/\n/g, "") + var pubkey = fieldPublicKey.text + var pubkeyArr = pubkey.split("\n") + if (pubkey.length) { addFirstRun("install -o \"$FIRSTUSER\" -m 700 -d \"$FIRSTUSERHOME/.ssh\"") - addFirstRun("install -o \"$FIRSTUSER\" -m 600 <(echo \""+pubkey+"\") \"$FIRSTUSERHOME/.ssh/authorized_keys\"") + addFirstRun("install -o \"$FIRSTUSER\" -m 600 <(printf \""+pubkey.replace(/\n/g, "\\n")+"\") \"$FIRSTUSERHOME/.ssh/authorized_keys\"") } addFirstRun("echo 'PasswordAuthentication no' >>/etc/ssh/sshd_config") addCloudInit(" lock_passwd: true") addCloudInit(" ssh_authorized_keys:") - addCloudInit(" - "+pubkey) + for (var i=0; i