aboutsummaryrefslogtreecommitdiff
path: root/kvmx-create
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2018-06-13 18:26:28 -0300
committerSilvio Rhatto <rhatto@riseup.net>2018-06-13 18:26:28 -0300
commitbc5a65b517273a3bc59ecd27fed5fce29fa7a6cb (patch)
tree947ef5635ad7e34daaee780dba8c4aa777a04a47 /kvmx-create
parent72827921d99f35686602ef8eb6ee56eaa6824b23 (diff)
downloadkvmx-bc5a65b517273a3bc59ecd27fed5fce29fa7a6cb.tar.gz
kvmx-bc5a65b517273a3bc59ecd27fed5fce29fa7a6cb.tar.bz2
Adds ssh_custom_pubkey config
Diffstat (limited to 'kvmx-create')
-rwxr-xr-xkvmx-create21
1 files changed, 18 insertions, 3 deletions
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