SSH 上的 RYSNC 不适用于受限 shell

Zam*_*ues 4 shell ssh rsync

我需要在我的生产服务器中授予一些 X 先生的访问权限,以便他可以将文件推送到我的服务器。由于没有必要给他 shell 访问权限,我决定使用受限 shell (rssh),以便他只能将文件复制到我的服务器而无法访问它。该文件将通过 SSH 使用 RSYNC 传输。

用于传输文件的命令是

rsync -ua  -e 'ssh -p 55'  /appdata/paths/ 192.168.4.172:/home/example/ 
Run Code Online (Sandbox Code Playgroud)

但是使用受限 shell 通过 SSH 进行 rsync 似乎无法正常工作

$ rsync -ua /appdata/paths/ -e 'ssh -p 565'
example@192.168.2.142:/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.  ##
Run Code Online (Sandbox Code Playgroud) #
  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]
Run Code Online (Sandbox Code Playgroud)

它工作正常scp,问题rsync仅在于

Ant*_*hon 5

您应该使用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
Run Code Online (Sandbox Code Playgroud)

如有必要,可以在此处此处找到更多详细信息