diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2018-06-13 18:26:28 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2018-06-13 18:26:28 -0300 |
commit | bc5a65b517273a3bc59ecd27fed5fce29fa7a6cb (patch) | |
tree | 947ef5635ad7e34daaee780dba8c4aa777a04a47 /kvmx-create | |
parent | 72827921d99f35686602ef8eb6ee56eaa6824b23 (diff) | |
download | kvmx-bc5a65b517273a3bc59ecd27fed5fce29fa7a6cb.tar.gz kvmx-bc5a65b517273a3bc59ecd27fed5fce29fa7a6cb.tar.bz2 |
Adds ssh_custom_pubkey config
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 |