flatcar-scripts/mod_for_test_scripts/300changePassword
Elly Jones 39ba1e5891 mod_image_for_test: add --{no,}standard_backdoor option.
The default is --standard_backdoor, which installs well-known ssh keys and sets
a well-known root password. Passing --nostandard_backdoor will cause
mod_image_for_test to use ssh keys from ~/.ssh/*.pub instead of the test keys
and not set the root password.

BUG=chromium-os:11744
TEST=Adhoc
Build an image with --standard_backdoor.
ssh -i ${SRC}/src/scripts/mod_for_test_scripts/ssh_keys/testing_rsa root@${DUT}
ssh root@${DUT} with 'test0000'
cat /root/.ssh/authorized_keys # check for the test key
Build an image with --nostandard_backdoor.
ssh -o PubkeyAuthentication=no root@${DUT} # this will fail
ssh root@${DUT} # this should work
cat /root/.ssh/authorized_keys # check for just your keys

Change-Id: Ie92fbc9d3815f478698c8c94d938daca2b5cd53e
Signed-off-by: Elly Jones <ellyjones@chromium.org>
Reviewed-on: http://gerrit.chromium.org/gerrit/3449
Reviewed-by: David Rochberg <rochberg@chromium.org>
2011-06-30 11:38:34 -07:00

19 lines
649 B
Bash
Executable File

#!/bin/bash
# Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
if [ "$BACKDOOR" -eq "0" ]; then
exit 0
fi
# reset root password to test0000 (4 zeroes).
TEMP_SHADOWFILE=${ROOT_FS_DIR}/etc/newshadow
CRYPTED_PASSWD="$(echo "test0000" | openssl passwd -1 -stdin)"
echo "root:${CRYPTED_PASSWD}:14500:0:::::" > ${TEMP_SHADOWFILE}
echo "chronos:${CRYPTED_PASSWD}:14500:0:99999::::" >> ${TEMP_SHADOWFILE}
sed '/^root/ d;/^chronos/ d' ${ROOT_FS_DIR}/etc/shadow >> ${TEMP_SHADOWFILE}
mv -f ${TEMP_SHADOWFILE} ${ROOT_FS_DIR}/etc/shadow