Skip to content

Commit 98ece14

Browse files
committed
Rename script because it's not only for root, support sudo
1 parent f72635e commit 98ece14

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

copy/opt/core/bin/generate-root-ssh-key renamed to copy/opt/core/bin/generate-ssh-key

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ if ! echo n | ssh-keygen -f "${ID_RSA}" -N '' &>/dev/null; then
1515
exit 1
1616
fi
1717

18+
# Try to use sudo for non root user
19+
[[ "${USER}" == "root" ]] && SUDO="sudo"
20+
1821
# Put information into mdata variables
19-
mdata-put "${USER}_ssh_rsa" < "${ID_RSA}"
20-
mdata-put "${USER}_ssh_rsa.pub" < "${ID_RSA}.pub"
22+
${SUDO} mdata-put "${USER}_ssh_rsa" < "${ID_RSA}"
23+
${SUDO} mdata-put "${USER}_ssh_rsa.pub" < "${ID_RSA}.pub"

0 commit comments

Comments
 (0)