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 等文件传输工具时)
- Command 'cd "xxxx"' failed with return code 1 and error message.-rbash: line 47: cd: restricted(当尝试使用 WinSCP 更改目录时)
Cause
rbash 实现是指通过禁用一些操作和功能来更改 shell 行为,这类操作和功能包括:
- 使用 cd 内置命令更改目录。
- 设置或取消设置 SHELL、PATH、ENV 或 BASH_ENV 变量的值。
- 指定包含斜杠的命令名。
- 将包含斜杠的文件名指定为内置命令的参数。
- 将包含斜杠的文件名指定为 hash 内置命令的 -p 选项的参数。
- 在启动时从 shell 环境导入函数定义。
- 在启动时从 shell 环境解析 SHELLOPTS 的值。
- 使用“>”、“>|”、“<>”、“>&”、“&>”和“>>”重定向运算符重定向输出。
- 使用 exec 内置命令将 shell 替换为另一个命令。
- 使用 enable 内置命令的 -f 和 -d 选项来添加或删除内置命令。
- 使用 enable 内置命令启用禁用的 shell 内置命令。
- 为内置命令指定 -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。
唯一的例外是正常的支持材料。对于每一组可用的支持材料,链接会自动置于主目录中,以方便下载。
提醒:在某些新版本的 Windows 10 中,您可能必须指定端口 (-P 22)。
下载示例:
上传示例:
请记住:
用户无法更改目录(不允许使用 cd),因此必须先将要从节点或设备下载的所有内容复制到 /home/service/user。
唯一的例外是正常的支持材料。对于每一组可用的支持材料,链接会自动置于主目录中,以方便下载。
如果您想要从其所在的目录直接下载文件,则必须首先从 PowerStore shell 找到完整路径,然后可以使用诸如 pscp(来自 windows cli)或 scp(来自 linux)等工具。
Windows pscp 示例:
语法:
| 用法: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 等)。
列出支持材料目录中的子目录的示例:
相同的原则适用于其他所有方面(grep 等)。
列出支持材料目录中的子目录的示例:
| [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.