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