diff --git a/conf/distro/oniro-openharmony-linux.conf b/conf/distro/oniro-openharmony-linux.conf index 2c37be43529567d145fc9a9adf4b9df7f875d17d..cc8a420ecbebf5408668913ba5499dd5e4406d31 100644 --- a/conf/distro/oniro-openharmony-linux.conf +++ b/conf/distro/oniro-openharmony-linux.conf @@ -40,6 +40,9 @@ INHERIT += "uninative" # instead. HOSTTOOLS += "ip ping ps scp ssh stty" +# Yocto does not have ssh-keygen-native, so we need to use ssh-keygen from host +HOSTTOOLS += "ssh-keygen" + # Default to enabling serial debug console on RaspberryPi # Placed here to amend the machine config living in meta-raspberrypi ENABLE_UART:raspberrypi4-64 ?= "1" diff --git a/recipes-openharmony/images/openharmony-standard-image-tests.bb b/recipes-openharmony/images/openharmony-standard-image-tests.bb index 98629f118a778b39fc0c67b0c5c0579554e81170..103b7f83e7d071a8bfe864acb887b8a7fef09c77 100644 --- a/recipes-openharmony/images/openharmony-standard-image-tests.bb +++ b/recipes-openharmony/images/openharmony-standard-image-tests.bb @@ -25,3 +25,13 @@ IMAGE_INSTALL += "ptest-runner" # install OpenHarmony components and ptests IMAGE_INSTALL += "openharmony-standard-ptest" + +# Pre-generate SSH host keys for quick first time SSH connection +ROOTFS_POSTPROCESS_COMMAND += "ssh_host_key_gen;" +SSH_HOST_KEY_TYPES="rsa ecdsa ed25519" +ssh_host_key_gen() { + mkdir -p "${IMAGE_ROOTFS}${sysconfdir}/ssh/" + for type in ${SSH_HOST_KEY_TYPES} ; do + ssh-keygen -f "${IMAGE_ROOTFS}${sysconfdir}/ssh/ssh_host_"$type"_key" -N '' -t $type + done +}