This commit is contained in:
陆柯 2022-11-18 16:37:37 +08:00
parent 77e27d795f
commit c0c4adefc4

View File

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