aboutsummaryrefslogtreecommitdiff
path: root/kvmx-create
diff options
context:
space:
mode:
Diffstat (limited to 'kvmx-create')
-rwxr-xr-xkvmx-create24
1 files changed, 18 insertions, 6 deletions
diff --git a/kvmx-create b/kvmx-create
index 31646eb..38405a3 100755
--- a/kvmx-create
+++ b/kvmx-create
@@ -94,7 +94,7 @@ function kvmx_sudo_run {
# Make sure there is provision config.
function kvmx_config {
- kvmx_user_config image /var/cache/qemu/debian/box.img "Destination image"
+ kvmx_user_config image /var/cache/qemu/debian/box.img "Destination image (ending in .img)"
kvmx_user_config size 3G "Image size"
kvmx_user_config format qcow2 "Image format: raw or qcow2"
kvmx_user_config method custom "Bootstrap method: custom or vmdeboostrap"
@@ -241,11 +241,23 @@ function kvmx_create_custom {
# Initial user
kvmx_sudo_run chroot $WORK/ useradd user -G sudo -s /bin/bash
- kvmx_sudo_run chroot $WORK/ mkdir -p /home/user/.ssh
- kvmx_sudo_run chroot $WORK/ chmod 700 /home/user/.ssh
- kvmx_sudo_run cp $DIRNAME/share/ssh/insecure_private_key.pub $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
+
+ if [ "$ssh_support" == "y" ];
+ if [ "$ssh_custom" == "y" ]; then
+ privkey="`dirname $image`/`basename $image .img`.key"
+ pubkey="${privkey}.pub"
+ ssh-keygen -t rsa -b 4096 -f $privkey -N '' -C "user@`basename $image .img`"
+ else
+ pubkey="$DIRNAME/share/ssh/insecure_private_key.pub"
+ fi
+
+ kvmx_sudo_run chroot $WORK/ mkdir -p /home/user/.ssh
+ kvmx_sudo_run chroot $WORK/ chmod 700 /home/user/.ssh
+ 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
+ fi
+
kvmx_sudo_run chroot $WORK/ chown -R user.user /home/user
echo 'user:user' | kvmx_sudo_run chroot $WORK/ chpasswd