diff --git a/meta/classes-recipe/rootfs-postcommands.bbclass
b/meta/classes-recipe/rootfs-postcommands.bbclass
index e81b69a239..920da94ba2 100644
--- a/meta/classes-recipe/rootfs-postcommands.bbclass
+++ b/meta/classes-recipe/rootfs-postcommands.bbclass
@@ -206,7 +206,9 @@ read_only_rootfs_hook () {
                # Also tweak the key location for dropbear in the same way.
                if [ -d ${IMAGE_ROOTFS}/etc/dropbear ]; then
                        if [ ! -e
${IMAGE_ROOTFS}/etc/dropbear/dropbear_rsa_host_key
]; then
-                               echo "DROPBEAR_RSAKEY_DIR=/var/lib/dropbear"
>> ${IMAGE_ROOTFS}/etc/default/dropbear
+                               if ! grep -q "^DROPBEAR_RSAKEY_DIR="
${IMAGE_ROOTFS}/etc/default/dropbear ; then
+                                       echo
