PowerStore:瞭解由於 rbash 和其他安全性實作所導致的 shell 限制
Summary: 為了強化整體安全性,我們決定藉由啟用 rbash (受限制的 bash shell) 和其他安全性實作,以鎖定 PowerStore Shell。另一個範例是,服務使用者的主資料夾是 /home/service/user,而不是預期中的 /home/service。這是服務使用者擁有寫入權限的少數幾個位置之一。
This article applies to
This article does not apply to
This article is not tied to any specific product.
Not all product versions are identified in this article.
Symptoms
由於這些措施,可能會發現錯誤:
rbash: cd: restricted(嘗試瀏覽目錄時)rbash: xxxx: restricted: cannot redirect output(嘗試使用「>」將輸出重新導向至檔案時)rbash: xxxx: command not found(嘗試執行未列於允許清單中的命令時)rbash: ./example_script: restricted: cannot specify `/' in command names(嘗試執行指令檔時)- Cannot initialize SFTP protocol. Is the host running an SFTP server? (嘗試設定 WinSCP 等檔案傳輸工具時)
- 命令「cd "xxxx"」失敗並顯示返回代碼 1 和錯誤訊息。-rbash: line 47: cd: restricted (嘗試使用 WinSCP 變更目錄時)
Cause
rbash 實作是指透過停用某些動作和功能來變更 shell 行為,包括:
- 使用 cd builtin 變更目錄。
- 設定或取消設定 SHELL、PATH、ENV 或 BASH_ENV 變數的值。
- 指定包含斜線的命令名稱。
- 指定包含斜線的檔案名稱作為 . builtin 命令的引數。
- 指定包含斜線的檔案名稱作為雜湊 builtin 命令 -p 選項的引數。
- 在啟動時從 shell 環境匯入功能定義。
- 在啟動時從 shell 環境分析 SHELLOPTS 的值。
- 使用「>」、「>|」、「<>」、「>&」、「&>」和「>>」重新導向運算子重新導向輸出結果。
- 使用 exec builtin,將 shell 更換為另一個命令。
- 使用 -f 和 -d 選項,為啟用的 builtin 新增或刪除 builtin 命令。
- 使用 enable builtin 命令來啟用停用的 shell builtin。
- 為命令 builtin 指定 -p 選項。
- 以「set +r」或「set +o restricted」關閉受限制模式。
如需詳細資訊,請參閱此處:
https://www.gnu.org/software/bash/manual/html_node/The-Restricted-Shell.html
Resolution
此處提供一些替代方案,能在具有上述限制的情況下,讓導覽和與系統互動更加輕鬆。
檔案傳輸
設定 WinSCP 等檔案傳輸工具時,請使用 SCP 而非 SFTP 或 FTP 通訊協定。
請記住:
使用者無法變更目錄 (不允許使用 cd),因此從節點或裝置下載的所有內容都必須先複製到 /home/service/user。
唯一的例外情況是一般 Support Materials。每組「Support Materials」的連結會自動放置在主目錄中以供下載。
注意:在某些新版本的 Windows 10 中,您可能需要指定連接埠 (-P 22)。
下載範例:
上傳範例:
請記住:
使用者無法變更目錄 (不允許使用 cd),因此從節點或裝置下載的所有內容都必須先複製到 /home/service/user。
唯一的例外情況是一般 Support Materials。每組「Support Materials」的連結會自動放置在主目錄中以供下載。
如果您要直接從檔案所在目錄下載檔案,您必須先從 PowerStore Shell 找到其完整路徑,然後便可以使用如 pscp (從 windows cli) 或 scp (從 linux) 等工具。
Windows pscp 範例:
語法:
| Usage: pscp [options] [user@]host:source target pscp [options] source [source...] [user@]host:target |
下載範例:
| pscp -scp -P 22 service@<appliance or node IP>:/path/to/file/to/download C:\Local\dowwnload-save\location pscp -scp service@xx.xx.xx.xx:/cyc_var/cyc_service/data_collection/xxxxxxxx/powerstore_xxxxxxxx_2020-05-06_00-00-00_service-data.tgz C:\LOGS service@xx.xx.xx.xx's password: powerstore_xxxxxxxxx | 10944 kB | x.x kB/s | ETA: 00:00:00 | 100% |
上傳範例:
| pscp -scp -P 22 C:\Logs\somefile.txt service@xx.xx.xx.xx:/home/service/user service@xx.xx.xx.xx's password: somefile.txt | 211 kB | 212.0 kB/s | ETA: 00:00:00 | 100% |
導覽
您無法使用「cd」瀏覽,但可以使用「ls」或「cat/less」等命令來列出目錄內容或讀取檔案。唯一的區別是,您必須始終使用完整路徑。
相同的原則亦適用於其他所有命令 (grep 等)。
以下範例列出「Support Materials」目錄中的子目錄:
相同的原則亦適用於其他所有命令 (grep 等)。
以下範例列出「Support Materials」目錄中的子目錄:
| [SVC:service@xxxxxxx-B user]$ ls -l /cyc_var/cyc_service/data_collection/ total 80 drwxrwsr-x+ 2 cyc cycg 4096 Apr 8 14:48 0941c91a-431d-4bfb-b5b2-062b02c45950 drwxrwsr-x+ 2 cyc cycg 4096 Apr 25 15:27 20439835-3654-4d93-af3b-ebfc0ae222fd drwxrwsr-x+ 2 cyc cycg 4096 Apr 19 15:27 3d2011a8-0aa2-48d7-9f3f-1f234df2abfb drwxrwsr-x+ 2 cyc cycg 4096 Apr 19 13:08 473ed1cb-0ebb-4bd6-bbf6-e87e61af8578 drwxrwsr-x+ 2 cyc cycg 4096 Apr 22 14:01 48a522ff-0aaa-4f83-a936-973f6f1097b2 drwxrwsr-x+ 2 cyc cycg 4096 Apr 22 15:26 4ba1375c-c23b-47c6-bc04-1498e3443b39 drwxrwsr-x+ 2 cyc cycg 4096 Apr 27 15:26 6faf6d88-58c6-4891-b001-8e0311e9e00d drwxrwsr-x+ 2 cyc cycg 4096 Apr 24 14:36 798b13df-70bb-4fd3-9691-608b735207e9 drwxrwsr-x+ 2 cyc cycg 4096 Apr 28 15:27 8187fc5d-d389-4676-a69f-23db20c06602 drwxrwsr-x+ 2 cyc cycg 4096 Apr 26 15:12 83cb57dc-dee3-4dae-8585-e3b670d4b52a drwxrwsr-x+ 2 cyc cycg 4096 Apr 18 12:50 a038d9ac-6ecc-4c49-8bb3-ae6623b418f6 drwxrwsr-x+ 2 cyc cycg 4096 Apr 21 13:43 b02e88fb-3f80-47a3-8f6d-3547afad7c35 drwxrwsr-x+ 2 cyc cycg 4096 Apr 24 15:26 b4bdd7c3-dbd0-4ac7-93ac-2e3e7ea1ff93 drwxrwsr-x+ 2 cyc cycg 4096 Apr 23 14:18 bf965b7e-e136-42ba-b46c-5fc565b6cf58 drwxrwsr-x+ 2 cyc cycg 4096 Apr 20 13:26 d96caca8-4395-4f15-aea1-60dd7a2490f5 drwxrwsr-x+ 2 cyc cycg 4096 Apr 23 15:26 e101bd57-fd3d-421a-b15a-341456a52f1f drwxrwsr-x+ 2 cyc cycg 4096 Apr 25 14:54 e57e625d-e393-4919-b0d1-5efd89042897 drwxrwsr-x+ 2 cyc cycg 4096 Apr 20 15:26 ea40f70d-3cbf-4c84-9643-627fdbf9f0bd drwxrwsr-x+ 2 cyc cycg 4096 Apr 21 15:26 ea9d95dd-1c72-4b2b-929a-ab6ec9cbedc1 drwxrwsr-x+ 2 cyc cycg 4096 Apr 17 12:34 fa02405b-ae24-4d7d-b178-97a99a2b717f [SVC:service@xxxxxxx-B user]$ |
Affected Products
PowerStore, PowerStore 1000X, PowerStore 1000T, PowerStore Expansion Enclosure, PowerStore 3000X, PowerStore 3000T, PowerStore Rack, PowerStore 5000X, PowerStore 5000T, PowerStore 7000X, PowerStore 7000T, PowerStore 9000X, PowerStore 9000TArticle Properties
Article Number: 000126621
Article Type: Solution
Last Modified: 27 Apr 2021
Version: 8
Find answers to your questions from other Dell users
Support Services
Check if your device is covered by Support Services.