Linux shell 将 sftp 用户限制到他们的主目录?

标签 linux shell sftp

我需要授予对我服务器上我的 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/

相关文章:

linux - 如何将我的旧站点从共享主机服务器移动到 VPS?

linux - 使用 shell 查找文件夹中没有指定文件模式的目录

.net - 从 SharpSSH 流式传输文件

linux - 在 Linux 中从 kernel/net/sched 文件夹加载不同的模块

c# - 在 Visual Studio 中将 .net core 应用程序部署到 Linux?

python - 如何使用 python file.py 从命令行运行类?

java - 使用 JSch 从 SFTP 服务器下载文件

c# - 从 C# 运行 Bash 命令

Python Shell : Global name 't' is not define. 我:但它是

python - 使用python将文件上传到SFTP