Chrooted SFTP 用户无法登录

Chrooted SFTP 用户无法登录

我正在尝试配置一个只能访问特定目录的用户。我在 SSH 中配置了一个 Chroot jail 并更改了它的主目录,但是使用 chroot 配置 internal-sftp 后,用户无法通过 sftp 客户端登录。

SSH 配置

Subsystem sftp internal-sftp

        Match Group sftpusers
        ChrootDirectory /var/www/latama
        ForceCommand internal-sftp
        X11Forwarding no
        AllowTCPForwarding no

我已经添加用户 latama sftpusers,以将 latama 加入 sfrpusers 组。

将其 /etc/passwd 更改为

latama:x:1002:1003:,,,:/var/www/latama:/bin/nologin

目录权限

drwxr-xr-x  8 latama www-data       4096 Nov  5 08:33 latama

当我尝试通过 sftp 连接时,会发生这种情况,并激活详细模式。

[email protected]'s password:
debug1: Authentication succeeded (password).
Authenticated to ourdomain.com ([175.75.145.125]:22).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: network
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
Connection to ourdomain.com closed by remote host.
Transferred: sent 1760, received 2316 bytes, in 0.0 seconds
Bytes per second: sent 812187.8, received 1068765.3
debug1: Exit status -1
Connection closed

答案1

chroot 文件夹需要由 root 拥有,并且仅应为所有者设置写入位。

相关内容