我需要授予对我服务器上我的 webroot 中的目录的 SFTP 访问权限。我已将 ben_files 设置为用户并将他的主目录设置为
/var/www/vhosts/mydomain.example/files
如果他使用普通的旧 FTP 连接,那一切都很好 - 他仅限于该目录,但要启用 SFTP,我必须将他添加到 bin/bash shell,这会突然打开我的整个服务器...
有没有办法让他访问 SFTP 但不打开我所有的目录?我真的希望他只能呆在家里。
最佳答案
OpenSSH≥4.8 支持 ChrootDirectory
指令。
添加到 /etc/sshd_config
或 /etc/ssh/sshd_config
或您设置的全局 sshd
配置文件是什么:
Match user ben_files # The following two directives force ben_files to become chrooted # and only have sftp available. No other chroot setup is required. ChrootDirectory /var/www/vhosts/mydomain.example/files ForceCommand internal-sftp # For additional paranoia, disallow all types of port forwardings. AllowTcpForwarding no GatewayPorts no X11Forwarding no
关于Linux shell 将 sftp 用户限制到他们的主目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1526919/