b880ef9017
Currently, the local-config and stackuser elements are intertwined. local-config installs an authorized_key for stackuser, if the stackuser element is in use. This change does two things: - add authorized_key for root from local-config element, regardeless of whether stackuser element is in use. - install key for stack user from stackuser element, only if local-config element is in use. Change-Id: I0d07b61404119ea0650c5c0fb98d6786adcf3ca9
29 lines
543 B
Bash
Executable File
29 lines
543 B
Bash
Executable File
#!/bin/bash
|
|
# Add the stack user we recommend folk use.
|
|
|
|
set -e
|
|
set -o xtrace
|
|
|
|
useradd -m stack -s /bin/bash
|
|
|
|
passwd stack <<EOF
|
|
stack
|
|
stack
|
|
EOF
|
|
|
|
|
|
cat > /etc/sudoers.d/stack <<eof
|
|
# the stack user sometimes requires passwordless
|
|
# sudo for scripted operations.
|
|
stack ALL=(ALL) NOPASSWD:ALL
|
|
eof
|
|
|
|
chmod 0440 /etc/sudoers.d/stack
|
|
visudo -c
|
|
|
|
if [ -e "/tmp/in_target.d/ssh-authorized-keys" ]; then
|
|
mkdir -p /home/stack/.ssh
|
|
cat /tmp/in_target.d/ssh-authorized-keys >> /home/stack/.ssh/authorized_keys
|
|
chown -R stack:stack /home/stack/.ssh
|
|
fi
|