From 4a3379eea3004535f10a89a3a42b3815fe07ffff Mon Sep 17 00:00:00 2001 From: Evan Klitzke Date: Sun, 27 May 2018 17:46:16 -0700 Subject: [PATCH] If id_rsa.pub doesn't exist, check for id_dsa.pub or id_ed25519.pub --- kvm-install-vm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/kvm-install-vm b/kvm-install-vm index 83b880c..86bf56d 100755 --- a/kvm-install-vm +++ b/kvm-install-vm @@ -318,6 +318,17 @@ function fetch_images () function check_ssh_key () { + local key + if [ -z "${PUBKEY}" ]; then + # Try to find a suitable key file. + for key in ~/.ssh/id_{rsa,dsa,ed25519}.pub; do + if [ -f "$key" ]; then + PUBKEY="$key" + break + fi + done + fi + if [ ! -f "${PUBKEY}" ] then # Check for existence of a pubkey, or else exit with message @@ -663,7 +674,7 @@ function set_defaults () RESIZE_DISK=false # Resize disk (boolean) IMAGEDIR=${HOME}/virt/images # Directory to store images BRIDGE=virbr0 # Hypervisor bridge - PUBKEY=${HOME}/.ssh/id_rsa.pub # SSH public key + PUBKEY="" # SSH public key DISTRO=centos7 # Distribution MACADDRESS="" # MAC Address PORT=-1 # Console port