PowerScale OneFS:配置 SFTP 和設定 chroot
Summary: 本文件說明如何透過安全檔案傳輸通訊協定 (SFTP) 允許存取 PowerScale 叢集。
Instructions
本文件說明如何允許透過 SFTP 存取 PowerScale 叢集。開始此過程時,需要記住一些限制和注意事項。
- 需要 SFTP 存取的使用者/群組必須具備
ISI_PRIV_LOGIN_SSH與其用戶關聯的許可權。 - SSH 和 SFTP 存取僅可在系統區域內運作。
- 並非所有 ssh 配置選項都可用;PowerScale 支援透過
isi ssh modify命令集。
除了這些因素之外,PowerScale 的運作方式和任何其他 FreeBSD OpenSSH 伺服器一樣。使用以下命令檢查叢集上的 OpenSSH 版本 ssh -V。
有關設置角色和許可權的指南,請參閱“管理角色和許可權”部分下的 CLI 或 Web 管理指南。
檢查使用者/群組是否有 ISI_PRIV_LOGIN_SSH
驗證相關使用者是否具有 ISI_PRIV_LOGIN_SSH。以下是預設管理員使用者的範例。
p930-1# isi auth mapping token admin | grep "LOGIN_SSH"
ISI_PRIV_LOGIN_SSH
如果沒有輸出,則必須將使用者分配到包含該特權的角色。有關如何執行此操作的更多詳細資訊,請參閱相關版本的“管理角色和許可權”下的管理指南
本機使用者的基本 SFTP 存取
確認正確的權限後,使用者應根據其使用者對應權杖,對檔案系統的各個部分具備 SFTP 存取權。
p930-1# sftp admin@localhost
(admin@localhost) Password:
Connected to localhost.
sftp> dir
sftp> cd ..
sftp> dir
admin ftp
基本 Chroot SFTP 存取
若要將使用者限制在檔案系統的特定子集,請使用 OpenSSH 的 ChrootDirectory 匹配語句中的功能。這會導致用戶端看到其登入路徑為 / 並使它們無法離開文件系統的該子集。 ChrootDirectory 但是,對整個路徑有嚴格的目錄許可權要求 ChrootDirectory 路徑中的每個目錄的 Posix 權限 root:wheel drwxr-xr-x 有關這方面的更多詳細資訊,請參閱 OpenSSH 維護者 手冊頁。
下面是用於實現的常見 Match 語句 ChrootDirectory 匹配組時。需要使用前三行 ChrootDirectory 沒有支援檔。最後一行限制了使用者利用 OpenSSH 中的 X11Forwarding 功能的能力。
Match Group admin
ChrootDirectory /ifs/sftp
ForceCommand internal-sftp
X11Forwarding no
以下是為 chroot 準備路徑的基本範例,當任何匹配的使用者可以寫入 /ifs/sftp/home 目錄。 root:wheel 擁有目錄 /ifs 和 /ifs/sftp,許可權設置為 755 ChrootDirectory 而 /ifs/sftp/home 許可權為 777,允許使用者寫入訪問許可權。
p930-1# isi auth settings acls modify --calcmode-group=group_only --calcmode-owner=owner_only
p930-1# mkdir -p /ifs/sftp/home
p930-1# chmod 755 /ifs/
p930-1# chmod 755 /ifs/sftp
p930-1# chmod 777 /ifs/sftp/home
p930-1# isi ssh settings modify --match="Match Group admin
dquote> ChrootDirectory /ifs/sftp
dquote> ForceCommand internal-sftp"
p930-1# sftp admin@localhost
(admin@localhost) Password:
Connected to localhost.
sftp> ls
home
sftp> pwd
Remote working directory: /
設定多個符合字串
在一個檔案中管理多個符合項目,然後將它們傳遞給我們的 isi ssh 命令。使用此過程可確保 sshd 驗證檔,並僅在檔有效時才應用更改。
以下是成功和失敗的例子。
p930-1# cat /ifs/sshMatches
Match Group admin
ChrootDirectory /ifs/sftp
ForceCommand internal-sftp
X11Forwarding no
Match All
X11Forwarding no
p930-1# sshd -t -f /ifs/sshMatches && isi ssh settings modify --match="$(cat /ifs/sshMatches)"
p930-1# sshd -t -f /ifs/sshMatchBad && isi ssh settings modify --match="$(cat /ifs/sshMatchBad)"
Missing Match criteria for Allk
/ifs/sshMatchBad line 6: Bad Match condition
符合字串注意事項。
設置匹配字串時,群集知道的任何使用者或組標識符都可以在“匹配使用者”或“匹配組”字串中使用。因此,參照 Active Directory 群組可以使用 RFC2307 domain\user。
如果使用者未路由至「符合使用者」字串中的正確路徑或設定,請驗證是否可以使用以下命令在叢集上尋找使用者 isi auth mapping token <username> 從您的匹配字串中獲取使用者名。
如果使用者未路由到匹配組字串中的正確路徑或設置,請使用以下命令驗證使用者是否為相關組的成員 isi auth mapping token <username> | grep <groupname>。
提供使用者名稱,然後從符合字串中取得群組名稱。
下面是一個使用者的示例,該使用者由於匹配組語句中的錯誤而未正確路由到路徑。User stateroot 在使用者無法正常運作時 prodroot 是,更正匹配組語句中使用的組名中的錯誤以解決此問題。
p930-1# isi auth mapping token stageroot | grep "LOGIN_SSH"
ISI_PRIV_LOGIN_SSH
p930-1# isi auth mapping token prodroot | grep "LOGIN_SSH"
ISI_PRIV_LOGIN_SSH
p930-1# cat /ifs/sshMatches
Match Group Stage-Root-SFTP
ChrootDirectory /ifs/home/Stage-Root
X11Forwarding no
ForceCommand internal-sftp
Match Group Prod-Root
ChrootDirectory /ifs/home/Prod-Root
X11Forwarding no
ForceCommand internal-sftp
p930-1# isi auth mapping token stageroot | grep "Stage-Root-SFTP"
p930-1# isi auth mapping token prodroot | grep "Prod-Root"
Name: Prod-Root
p930-1# isi auth mapping token stageroot | grep "Stage-Root"
Name: Stage-Root
舊版組態
在 OneFS 8.2 之前,可以實現相同的功能,但 isi ssh 命令尚不存在。而不是使用 isi ssh settings modify --match="" 編輯檔案 /etc/mcp/templates/sshd_config 使用上述步驟將使用的相同匹配字串。將它們新增到末尾 /etc/mcp/templates/sshd_config。
所提供的指示應適用於 OneFS 8.2 之前的 OneFS 版本,但在升級至支援應用程式發展介面 (API) 的 OneFS 版本後,將會移除以此方式進行的任何組態調整。使用 SFTP 存取的使用者仍需要 ISI_PRIV_LOGIN_SSH 特權。