From 1a419315292dae56e69cf57765eb5e883c3cdcf9 Mon Sep 17 00:00:00 2001 From: Elie Kheirallah Date: Tue, 18 Jul 2023 21:03:59 +0000 Subject: [PATCH] tools: examples: network - uncomment RSA and add info Uncommented the line that injetcs the RSA key to allow for SSH connections to the VM without initial login. Add more information that if the file is missing, an initial login to change passwords is required. BUG=N/A TEST=mdbook build Change-Id: Ie0f94da693e04319b7b098df8bfe044ceeeeb8a9 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4698613 Commit-Queue: Elie Kheirallah Reviewed-by: Daniel Verkamp --- tools/examples/example_network | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/examples/example_network b/tools/examples/example_network index 40dc1f7af3..fcd608ed82 100755 --- a/tools/examples/example_network +++ b/tools/examples/example_network @@ -22,13 +22,19 @@ if ! [ -f rootfs ]; then # $SRC=/path/to/crosvm --copy-in "$SRC/guest/01-netcfg.yaml:/etc/netplan/" - # Install sshd and authorized key for the user. + # Install sshd. --install openssh-server - # OPTIONAL: inject RSA public key as known key - # --ssh-inject "$USER:file:$HOME/.ssh/id_rsa.pub" -o rootfs ) + + # Inject authorized key for the user. + # If the SSH RSA public key file is missing, you will need to login to + # the VM the first time and change passwords before you can login via SSH. + ID_RSA_PUB="$HOME/.ssh/id_rsa.pub" + if [ -r "${ID_RSA_PUB}" ]; then + builder_args+=("--ssh-inject" "${USER}:file:${ID_RSA_PUB}") + fi virt-builder ubuntu-20.04 "${builder_args[@]}" # ANCHOR_END: build