From bc5a65b517273a3bc59ecd27fed5fce29fa7a6cb Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Wed, 13 Jun 2018 18:26:28 -0300 Subject: Adds ssh_custom_pubkey config --- kvmx-create | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'kvmx-create') diff --git a/kvmx-create b/kvmx-create index 56b08b6..a00f78c 100755 --- a/kvmx-create +++ b/kvmx-create @@ -451,9 +451,19 @@ EOF if [ "$ssh_support" == "y" ]; then if [ "$ssh_custom" == "y" ]; then - privkey="$sshdir/ssh/$hostname.key" - pubkey="${privkey}.pub" - __kvmx_ssh_keygen $privkey "$user@$hostname" + if [ ! -z "$ssh_custom_pubkey" ]; then + pubkey="$sshdir/ssh/$hostname.key.pub" + + if [ -e "$ssh_custom_pubkey" ]; then + cp $ssh_custom_pubkey $pubkey + else + echo $ssh_custom_pubkey > $pubkey + fi + else + privkey="$sshdir/ssh/$hostname.key" + pubkey="${privkey}.pub" + __kvmx_ssh_keygen $privkey "$user@$hostname" + fi else pubkey="$DIRNAME/share/ssh/insecure_private_key.pub" fi @@ -463,6 +473,11 @@ EOF kvmx_sudo_run cp $pubkey $WORK/home/$user/.ssh/authorized_keys kvmx_sudo_run chroot $WORK/ chmod 600 /home/$user/.ssh/authorized_keys kvmx_sudo_run touch $WORK/home/$user/.hushlogin + + # Cleanup temporary file if needed + if [ ! -z "$ssh_custom_pubkey" ]; then + rm $pubkey + fi fi kvmx_sudo_run chroot $WORK/ chown -R $user.$user /home/$user -- cgit v1.2.3