簡體   English   中英

在Azure自定義腳本擴展和AWS Userdata -Linux中運行時獲得不同的文件權限

[英]Getting different file permission when running in Azure Custom Script extension and in AWS Userdata -Linux

我在Azure linux(使用自定義腳本擴展名)和AWS Linux框(使用用戶數據)中運行相同的腳本,但是當腳本完成后,我可以看到在兩台服務器中創建的相同文件具有不同的文件權限。

更新:現在已解決。 我終於找到了答案。 是在Linux上強制執行的selinux。 禁用它解決了我所有的問題。

在Azure中,可以使用Azure自定義腳本擴展來創建文件,Azure將使用root帳戶來創建文件。

使用自定義腳本擴展名創建file1 ,您可以在/var/lib/waagent/Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.2/download/0找到file1,如下所示:

root@jasonvm:/var/lib/waagent/Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.2/download/0# pwd
/var/lib/waagent/Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.2/download/0
root@jasonvm:/var/lib/waagent/Microsoft.OSTCExtensions.CustomScriptForLinux-1.5.2.2/download/0# ls -al
total 12
drwxr-xr-x 2 root root 4096 Feb 21 01:50 .
drwxr-xr-x 3 root root 4096 Feb 21 01:50 ..
-rw-r--r-- 1 root root    0 Feb 21 01:50 errout
-rw-r--r-- 1 root root    0 Feb 21 01:50 file1
---x------ 1 root root   11 Feb 21 01:50 script.sh
-rw-r--r-- 1 root root    0 Feb 21 01:50 stdout

根據輸出,Azure使用root帳戶創建文件,因此權限與使用root帳戶創建文件相同,權限為644

我不太擅長AWS,您可以使用ls -al來檢入AWS。

希望這可以幫助。


更新:

請在Azure Linux VM和AWS Linux VM中檢查umask

Azure Linux VM使用umask默認值0022 ,因此新文件的權限為644,新目錄的權限為755

在此處輸入圖片說明

[root@jason]# umask
0022

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM