diff --git a/userspace/rootfs_override/etc/init.d/sshd.sh b/userspace/rootfs_override/etc/init.d/sshd.sh
index daeaab46efbcc13255229f350b0eec38a37322f9..5374a68bcc13fb216d3102a398f62186b098c8e9 100755
--- a/userspace/rootfs_override/etc/init.d/sshd.sh
+++ b/userspace/rootfs_override/etc/init.d/sshd.sh
@@ -39,10 +39,13 @@ start() {
 	# Make sure ssh directory exists
 	mkdir -p /etc/ssh
 
+	# Copy keys from permanent location if available
 	if [ -d "$permanent_path_ssh" ] ; then
 		cp "$permanent_path_ssh"/ssh_host_*_key* /etc/ssh/
 	fi
 
+	mkdir -p "$permanent_path_ssh"
+
 	# Check for the ssh keys
 	if     [ ! -f /etc/ssh/ssh_host_rsa_key ] \
         || [ ! -f /etc/ssh/ssh_host_dsa_key ] \
@@ -50,7 +53,6 @@ start() {
         || [ ! -f /etc/ssh/ssh_host_ed25519_key ]; then
 # 		echo -n "generating ssh keys... "
 		/usr/bin/ssh-keygen -A
-		mkdir -p "$permanent_path_ssh"
 		cp /etc/ssh/ssh_host_*_key* "$permanent_path_ssh"
 	fi