This commit is contained in:
陆柯 2022-06-19 09:14:44 +08:00
parent ded2ef13c7
commit 199eac4c42
2 changed files with 3 additions and 5 deletions

View File

@ -43,8 +43,7 @@ then
read -p ">>> " CopyOrLinkScripts read -p ">>> " CopyOrLinkScripts
for homescript in $homescriptlist for homescript in $homescriptlist
do do
rm -fr $homescript.backup mv $homescript $homescript.backup-[$(date +%Y%m%d-%H%M%S)]
mv $homescript $homescript.backup
if [ $CopyOrLinkScripts = 'l' ] if [ $CopyOrLinkScripts = 'l' ]
then then
echo "--- Linking $SourcePath/$homescript to $HomePath/$homescript ..." echo "--- Linking $SourcePath/$homescript to $HomePath/$homescript ..."
@ -62,8 +61,7 @@ then
echo "--- Linking $SourcePath/authorized_keys to $HomePath/.ssh/authorized_keys ..." echo "--- Linking $SourcePath/authorized_keys to $HomePath/.ssh/authorized_keys ..."
mkdir -p $HomePath/.ssh mkdir -p $HomePath/.ssh
chmod 700 $HomePath/.ssh chmod 700 $HomePath/.ssh
rm -fr $HomePath/.ssh/authorized_keys.backup mv $HomePath/.ssh/authorized_keys $HomePath/.ssh/authorized_keys.backup-[$(date +%Y%m%d-%H%M%S)]
mv $HomePath/.ssh/authorized_keys $HomePath/.ssh/authorized_keys.backup
ln -s $SourcePath/.ssh/authorized_keys $HomePath/.ssh/authorized_keys ln -s $SourcePath/.ssh/authorized_keys $HomePath/.ssh/authorized_keys
elif [ $CopyOrLinkOrOmitAuthorizedKeys = 'a' ] elif [ $CopyOrLinkOrOmitAuthorizedKeys = 'a' ]
then then

View File

@ -14,4 +14,4 @@ scp ~/.ssh/id_rsa.pub $REMOTEHOST:~/tmp.pub
ssh $REMOTEHOST "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat ~/tmp.pub >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys && rm -f ~/tmp.pub" ssh $REMOTEHOST "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat ~/tmp.pub >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys && rm -f ~/tmp.pub"
echo ~/.ssh/id_rsa.pub is appended to $REMOTEHOST:~/.ssh/authorized_keys echo "~/.ssh/id_rsa.pub is appended to $REMOTEHOST:~/.ssh/authorized_keys"