aboutsummaryrefslogtreecommitdiff
path: root/kvmx-create
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2018-06-13 20:24:47 -0300
committerSilvio Rhatto <rhatto@riseup.net>2018-06-13 20:24:47 -0300
commitb48a6c3a57aa25ae396de581d7e276754580bffc (patch)
tree15943987e03dd7405418a9860bc7fc229ec5639b /kvmx-create
parent4f4c8ce9d34af8ccf38cecd35121206b2d29fc56 (diff)
downloadkvmx-b48a6c3a57aa25ae396de581d7e276754580bffc.tar.gz
kvmx-b48a6c3a57aa25ae396de581d7e276754580bffc.tar.bz2
SSH fixes at kvmx-create
Diffstat (limited to 'kvmx-create')
-rwxr-xr-xkvmx-create51
1 files changed, 27 insertions, 24 deletions
diff --git a/kvmx-create b/kvmx-create
index 6dc16c9..260b7f5 100755
--- a/kvmx-create
+++ b/kvmx-create
@@ -447,8 +447,8 @@ EOF
# Save host SSH key fingerprints
for key in $WORK/etc/ssh/*pub; do
- ssh-keygen -l -f $key >> `basename $key`.sha256
- ssh-keygen -l -E md5 -f $key >> `basename $key`.md5
+ ssh-keygen -l -f $key >> $sshdir/`basename $key`.sha256
+ ssh-keygen -l -E md5 -f $key >> $sshdir/`basename $key`.md5
done
# Sudo
@@ -464,36 +464,39 @@ EOF
kvmx_sudo_run chroot $WORK/ useradd $user -G sudo -s /bin/bash
fi
- if [ "$ssh_support" == "y" ]; then
- if [ "$ssh_custom" == "y" ]; then
- if [ ! -z "$ssh_custom_pubkey" ]; then
- pubkey="$sshdir/ssh/$hostname.key.pub"
+ # Initial user homedir
+ mkdir -p $WORK/home/$user
- if [ -e "$ssh_custom_pubkey" ]; then
- cp $ssh_custom_pubkey $pubkey
- else
- echo $ssh_custom_pubkey > $pubkey
- fi
+ #if [ "$ssh_support" == "y" ]; then
+ if [ "$ssh_custom" == "y" ]; then
+ if [ ! -z "$ssh_custom_pubkey" ]; then
+ pubkey="$sshdir/ssh/$hostname.key.pub"
+
+ if [ -e "$ssh_custom_pubkey" ]; then
+ cp $ssh_custom_pubkey $pubkey
else
- privkey="$sshdir/ssh/$hostname.key"
- pubkey="${privkey}.pub"
- __kvmx_ssh_keygen $privkey "$user@$hostname"
+ echo $ssh_custom_pubkey > $pubkey
fi
else
- pubkey="$DIRNAME/share/ssh/insecure_private_key.pub"
+ 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
- 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
+ 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
- # Cleanup temporary file if needed
- if [ ! -z "$ssh_custom_pubkey" ]; then
- rm $pubkey
- fi
+ # 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
echo "$user:$password" | kvmx_sudo_run chroot $WORK/ chpasswd