diff options
-rwxr-xr-x | kvmx | 13 | ||||
-rwxr-xr-x | kvmx-create | 3 |
2 files changed, 10 insertions, 6 deletions
@@ -116,8 +116,9 @@ function __kvmx_initialize { LOGFILE="$STATE_DIR/log" SPICEFILE="$STATE_DIR/spice" - if [ -e "$STORAGE/$VM.key" ]; then - SSHKEY="$STORAGE/$VM.key" + if [ -e "$STORAGE/ssh/$VM.key" ]; then + mkdir -p "$STORAGE/ssh" + SSHKEY="$STORAGE/ssh/$VM.key" else SSHKEY="$APP_BASE/share/ssh/insecure_private_key" fi @@ -191,7 +192,7 @@ function kvmx_up { if [ ! -z "$basebox" ]; then if [ -e "$GLOBAL_USER_CONFIG_FOLDER/$basebox" ]; then baseimage="`kvmx list_image $basebox`" - basekey="`basename $baseimage .img`.key" + basekey="`dirname $baseimage`/ssh/`basename $baseimage .img`.key" if [ ! -e "$baseimage" ]; then echo "$BASENAME: could not find basebox $baseimage. Please create it first." @@ -202,7 +203,9 @@ function kvmx_up { cp $baseimage $image if [ -e "$basekey" ]; then - imagekey="`basename $image .img`.key" + imagekey="`dirname $image`/ssh/`basename $image .img`.key" + mkdir "`dirname $image`/ssh" + cp $basekey $imagekey cp $basekey.pub $imagekey.pub @@ -674,7 +677,7 @@ function kvmx_log { # Rotate SSH keys function kvmx_rotate_sshkeys { # Generate new keypair - SSHKEY="$STORAGE/$VM.key" + SSHKEY="$STORAGE/ssh/$VM.key" $DIRNAME/kvmx-keygen $SSHKEY.new "$user@`basename $image .img`" # Replace pubkey on server diff --git a/kvmx-create b/kvmx-create index 204f2e0..fed0292 100755 --- a/kvmx-create +++ b/kvmx-create @@ -246,8 +246,9 @@ function kvmx_create_custom { if [ "$ssh_support" == "y" ]; if [ "$ssh_custom" == "y" ]; then - privkey="`dirname $image`/`basename $image .img`.key" + privkey="`dirname $image`/ssh/`basename $image .img`.key" pubkey="${privkey}.pub" + mkdir -p "`dirname $privkey`" $DIRNAME/kvmx-keygen $privkey "$user@`basename $image .img`" else pubkey="$DIRNAME/share/ssh/insecure_private_key.pub" |