Skip to content

Commit

Permalink
Look for ssh_authorized_keys without dashes
Browse files Browse the repository at this point in the history
The documented spelling of ssh-authorized-keys is actually
invalid according to jsonschema, even if accepted by python.

Signed-off-by: Anders F Björklund <[email protected]>
  • Loading branch information
afbjorklund committed Apr 7, 2024
1 parent 5a09f68 commit c370bfe
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lima-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ echo "${LIMA_CIDATA_USER} ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/90-lima-users
# Create authorized_keys
LIMA_CIDATA_SSHDIR="${LIMA_CIDATA_HOMEDIR}"/.ssh
mkdir -p -m 700 "${LIMA_CIDATA_SSHDIR}"
awk '/ssh-authorized-keys/ {flag=1; next} /^ *$/ {flag=0} flag {sub(/^ +- /, ""); gsub(/^"|"$/,""); gsub("\\\\\"", "\""); print $0}' \
# Lima currently uses "ssh-authorized-keys", which is invalid and should be "ssh_authorized_keys"
awk '/ssh[-_]authorized[-_]keys/ {flag=1; next} /^ *$/ {flag=0} flag {sub(/^ +- /, ""); gsub(/^"|"$/,""); gsub("\\\\\"", "\""); print $0}' \
"${LIMA_CIDATA_MNT}"/user-data >"${LIMA_CIDATA_SSHDIR}"/authorized_keys
LIMA_CIDATA_GID=$(id -g "${LIMA_CIDATA_USER}")
chown -R "${LIMA_CIDATA_UID}:${LIMA_CIDATA_GID}" "${LIMA_CIDATA_SSHDIR}"
Expand Down

0 comments on commit c370bfe

Please sign in to comment.