限制ssh用户login到php脚本的权限

我需要制定一个限制用户(在Ubuntu 10.04的SSHlogin)的方式允许执行以下操作:

  • 仅上传txt文件(通过SCP或SFTP)
  • 执行php命令“php somefile.php”

这可行吗?

您可以将用户shell(在/etc/passwd )更改为自定义shell …

简单的例子:

 #!/bin/bash php somefile.php # You might need to give the full path to the php-bin. bash -r -c read 

将其保存在/bin ,将其添加到/etc/shells并使其可运行。 用户仍然可以使用SCP和SFTP,但是当他尝试打开一个shell时,php将运行。 如果他进入,壳将closures。

通过Web服务器提供php脚本可能更容易,并通过同一站点提供文本file upload。 这样,你可以非常好地控制什么是允许的,什么不是。