File: 62-ssh-key

package info (click to toggle)
python-diskimage-builder 3.39.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 5,704 kB
  • sloc: sh: 7,474; python: 6,454; makefile: 37
file content (22 lines) | stat: -rwxr-xr-x 592 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash
# Save user SSH public key if available.
# XXX: Obviously not suitable for downloadable images.

if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
    set -x
fi
set -eu
set -o pipefail

if [ "$DIB_LOCAL_CONFIG_USERNAME" == "root" ]; then
    DIR_NAME=${DIB_LOCAL_CONFIG_USERNAME}
else
    DIR_NAME=home/${DIB_LOCAL_CONFIG_USERNAME}
fi

if [ -e "/tmp/in_target.d/ssh-authorized-keys" ]; then
    mkdir -p /${DIR_NAME}/.ssh
    cat /tmp/in_target.d/ssh-authorized-keys >> /${DIR_NAME}/.ssh/authorized_keys
    chmod 0700 /${DIR_NAME}/.ssh
    chmod 0600 /${DIR_NAME}/.ssh/authorized_keys
fi