Skip to content

Commit

Permalink
Rename script because it's not only for root, support sudo
Browse files Browse the repository at this point in the history
  • Loading branch information
drscream committed Nov 8, 2021
1 parent f72635e commit 98ece14
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ if ! echo n | ssh-keygen -f "${ID_RSA}" -N '' &>/dev/null; then
exit 1
fi

# Try to use sudo for non root user
[[ "${USER}" == "root" ]] && SUDO="sudo"

# Put information into mdata variables
mdata-put "${USER}_ssh_rsa" < "${ID_RSA}"
mdata-put "${USER}_ssh_rsa.pub" < "${ID_RSA}.pub"
${SUDO} mdata-put "${USER}_ssh_rsa" < "${ID_RSA}"
${SUDO} mdata-put "${USER}_ssh_rsa.pub" < "${ID_RSA}.pub"

0 comments on commit 98ece14

Please sign in to comment.