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
This commit is contained in:
xiexs 2015-10-08 10:29:42 -04:00
parent f6b70fa9b0
commit 96179231e7
1 changed files with 5 additions and 5 deletions

View File

@ -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