透過 SSH 的 RYSNC 不適用於受限 shell

透過 SSH 的 RYSNC 不適用於受限 shell

我需要授予對我的生產伺服器中的某些 X 先生的存取權限,以便他可以將檔案推送到我的伺服器。由於沒有必要給他 shell 存取權限,我決定使用受限 shell (rssh),這樣他只能將檔案複製到我的伺服器而無法存取它。該檔案將使用 RSYNC over SSH 進行傳輸。

用於傳輸檔案的命令是

rsync -ua  -e 'ssh -p 55'  /appdata/paths/ 192.168.4.172:/home/example/ 

但是使用受限 shell 透過 SSH 進行 rsync 似乎無法正常運作

$ rsync -ua /appdata/paths/ -e 'ssh -p 565'
[email protected]:/home/example/
#################################################################################################################

 This service is restricted to authorized users only. All activities on this system     
 are logged.            ##
  ##   Unauthorized access will be fully investigated and reported to the appropriate     
 law enforcement agencies.  ##
#
  insecure -e option not allowed.
 This account is restricted by rssh.
 Allowed commands: scp rsync

  If you believe this is in error, please contact your system administrator.

  rsync: connection unexpectedly closed (0 bytes received so far) [sender]
  rsync error: error in rsync protocol data stream (code 12) at io.c(600) [sender=3.0.6]

它運作正常,問題僅scp在於rsync

答案1

您應該使用rrsync(可能在您的系統上可用gzip壓縮,例如在/usr/share/doc/rsync/scripts/)並將authorized_keys檔案中的一行與安裝在那裡的rsync公鑰相關聯:

command="$HOME/bin/rrsync -ro ~/rsyncdir/",no-agent-forwarding,no-port-forwarding,no-pty,no-user-rc,no-X11-forwarding

如果需要的話可以找到更多細節這裡這裡

相關內容