Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Install a static ssh host key, for use in development
- IMAGE_FEATURES[validitems] += "dev-ssh-hostkey"
- ROOTFS_POSTPROCESS_COMMAND += "${@feature_enabled('debug-tweaks dev-ssh-hostkey', 'dev_ssh_hostkey; ', d)}"
- DEVELOPER_SSH_HOSTKEY ?= "${OE_USER_DIR}/ssh-keys/developer_host_rsa"
- DEVELOPER_SSH_HOSTKEY_CREATE ?= "1"
- dev_ssh_hostkey() {
- local key_src="${DEVELOPER_SSH_HOSTKEY}"
- [ "$key_src" ] || {
- bbnote "DEVELOPER_SSH_HOSTKEY not set; set to a filename "\
- "to have it installed as the SSH host key"
- return 0
- }
- [ -d "${sshconfdir}" ] || {
- bbnote "SSH does not seem to be installed in the image, will "\
- "not install host key"
- return 0
- }
- dev_ssh_verify_hostkey "$key_src" || {
- bbwarn "Developer SSH hostkey '$key_src' does not exist; ignoring"
- return 0
- }
- bbnote "Installing '$key_src' as the SSH host key for the image (debug-tweaks)"
- install -m 0600 "$key_src" "${sshconfdir}/ssh_host_rsa_key"
- install -m 0644 "$key_src.pub" "${sshconfdir}/ssh_host_rsa_key.pub"
- }
- # dev_ssh_verify_hostkey returns success if the ssh key, given as parameter,
- # exists. If the key does not exist, the function will generate it unless
- # requested not to by setting DEVELOPER_SSH_HOSTKEY_CREATE to anything
- # other than Y, y, 1 or yes.
- dev_ssh_verify_hostkey() {
- [ ! -e "$1" ] || return 0
- case "${DEVELOPER_SSH_HOSTKEY_CREATE}" in
- [Yy1]|yes) ;;
- *) return 1 ;;
- esac
- # If the specified directory doesn't exist, create it first
- [ -d "${1%/*}" ] || mkdir -p "${1%/*}"
- ssh-keygen -t rsa -N '' -b 2048 \
- -C "developer hostkey for $LOGNAME" \
- -f "$1" ||
- bbwarn "ssh-keygen failed to generate a developer hostkey"
- }
Advertisement
Add Comment
Please, Sign In to add comment