diff options
Diffstat (limited to 'kvmx-create')
-rwxr-xr-x | kvmx-create | 21 |
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 |