u
This commit is contained in:
parent
77e27d795f
commit
c0c4adefc4
@ -35,11 +35,15 @@ fi
|
||||
if [ "$2" == 'root' ]
|
||||
then
|
||||
HomePath=/root
|
||||
TheUser=root
|
||||
elif [ "$2" ]
|
||||
then
|
||||
HomePath=/home/$2
|
||||
TheUser=$2
|
||||
else
|
||||
# 可能是 root 或其他
|
||||
HomePath=~
|
||||
TheUser=`whoami`
|
||||
fi
|
||||
|
||||
if [ -d "$HomePath" ]
|
||||
@ -66,6 +70,9 @@ then
|
||||
done
|
||||
echo
|
||||
|
||||
if [ "$TheUser" != 'root' ]
|
||||
then
|
||||
|
||||
mkdir -p $HomePath/.ssh
|
||||
chmod 700 $HomePath/.ssh
|
||||
# 注意,由 root 为新用户创建的配置文件的 owner 是 root,而不是新用户,导致新用户无法读取该文件而密钥登录失败,因此要重设 owner。
|
||||
@ -90,6 +97,8 @@ then
|
||||
fi
|
||||
echo
|
||||
|
||||
fi
|
||||
|
||||
popd
|
||||
else
|
||||
echo "!!! Not existing $HomePath, please try again."
|
||||
|
Loading…
Reference in New Issue
Block a user