Skip to content

Commit

Permalink
Add docs for new --sshcopyid behavior and adjust coding style
Browse files Browse the repository at this point in the history
Use "${foo}" instead of "$foo" and messages should start with uppercase
letter.
  • Loading branch information
mika committed Jun 3, 2020
1 parent c69705b commit 35d6c28
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
16 changes: 8 additions & 8 deletions grml-debootstrap
Expand Up @@ -1798,8 +1798,8 @@ iface ${interface} inet dhcp
fi

if [ -n "${SSHCOPYID}" ] ; then
AUTHORIZED_KEYS_SOURCE=${AUTHORIZED_KEYS_SOURCE:-$HOME/.ssh/authorized_keys}
AUTHORIZED_KEYS_TARGET=${AUTHORIZED_KEYS_TARGET:-$MNTPOINT/root/.ssh/}
AUTHORIZED_KEYS_SOURCE=${AUTHORIZED_KEYS_SOURCE:-${HOME}/.ssh/authorized_keys}
AUTHORIZED_KEYS_TARGET=${AUTHORIZED_KEYS_TARGET:-${MNTPOINT}/root/.ssh/}
if ssh-add -L >/dev/null 2>&1 ; then
einfo "Use locally available public keys to authorise root login on the target system as requested via --sshcopyid option."
mkdir -p "${MNTPOINT}"/root/.ssh
Expand All @@ -1811,14 +1811,14 @@ iface ${interface} inet dhcp
eend 1
bailout 1
fi
elif [ -f "$AUTHORIZED_KEYS_SOURCE" ]; then
einfo "copying '$AUTHORIZED_KEYS_SOURCE' to '$AUTHORIZED_KEYS_TARGET' as requested via --sshcopyid option."
mkdir -p "$AUTHORIZED_KEYS_TARGET"
chmod 0700 "$AUTHORIZED_KEYS_TARGET"
if cp "$AUTHORIZED_KEYS_SOURCE" "$AUTHORIZED_KEYS_TARGET" ; then
elif [ -f "${AUTHORIZED_KEYS_SOURCE}" ]; then
einfo "Copying '${AUTHORIZED_KEYS_SOURCE}' to '${AUTHORIZED_KEYS_TARGET}' as requested via --sshcopyid option."
mkdir -p "${AUTHORIZED_KEYS_TARGET}"
chmod 0700 "${AUTHORIZED_KEYS_TARGET}"
if cp "${AUTHORIZED_KEYS_SOURCE}" "${AUTHORIZED_KEYS_TARGET}" ; then
eend 0
else
eerror "Error: copying '$AUTHORIZED_KEYS_SOURCE' to '$AUTHORIZED_KEYS_TARGET' failed"
eerror "Error: copying '${AUTHORIZED_KEYS_SOURCE}' to '${AUTHORIZED_KEYS_TARGET}' failed"
eend 1
bailout 1
fi
Expand Down
6 changes: 6 additions & 0 deletions grml-debootstrap.8.txt
Expand Up @@ -229,10 +229,16 @@ Options and environment variables
*--sshcopyid*::

Use locally available public keys to authorise root login on the target system.

Similar to ssh-copy-id(1) (without the -i option) it checks if `ssh-add -L`
provides any output, and if so those keys are appended to
_/root/.ssh/authorized_keys_ (creating the file and directory (with mode 0700)).

Iff invocation of `ssh-add -L` fails and file _$HOME/.ssh/authorized_keys_ exists,
then it installs _$HOME/.ssh/authorized_keys_ as _/root/.ssh/authorized_keys_on
the target system. If a different file than _$HOME/.ssh/authorized_keys_ should
be used, the environment variable _AUTHORIZED_KEYS_SOURCE_ can be used.

*-t*, *--target* _target_::

Target partition (/dev/...) or directory (anything else without /dev at the
Expand Down

0 comments on commit 35d6c28

Please sign in to comment.