From 96179231e70b326f04f9187cbca7ec6b4db68c71 Mon Sep 17 00:00:00 2001 From: xiexs Date: Thu, 8 Oct 2015 10:29:42 -0400 Subject: [PATCH] Replace the hard-code home directory with a tilde. Hard-coded user`s home directory will cause problems, if a customized base directory is specified by the HOME variable into the /etc/default/useradd. For instance, $cat /etc/default/useradd #HOME=/home HOME=/tmp/ Then, the directory "/tmp/" (not "/home/") will be the default prefix for the home directory of the new user which is created by "useradd" with "--create-home" option. Change-Id: I4e343955a187195652b1ecca5982869bd5c8133c --- scripts/update-admin-ssh-keys | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/update-admin-ssh-keys b/scripts/update-admin-ssh-keys index 90e49034..bff095b2 100755 --- a/scripts/update-admin-ssh-keys +++ b/scripts/update-admin-ssh-keys @@ -65,11 +65,11 @@ for FILE in tripleo-cloud/ssh-keys/*; do if ! getent passwd $USER &>/dev/null; then useradd --create-home --user-group $USER fi - mkdir -p /home/$USER/.ssh - chown -R $USER:$USER /home/$USER/.ssh - chmod 700 /home/$USER/.ssh - cp -f $FILE /home/$USER/.ssh/authorized_keys - chmod 600 /home/$USER/.ssh/authorized_keys + eval mkdir -p ~$USER/.ssh + eval chown -R $USER:$USER ~$USER/.ssh + eval chmod 700 ~$USER/.ssh + eval cp -f $FILE ~$USER/.ssh/authorized_keys + eval chmod 600 ~$USER/.ssh/authorized_keys touch /etc/sudoers.d/$USER chmod 0440 /etc/sudoers.d/$USER echo "$USER ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/$USER