7

我正在尝试使用 Amazon EC2 服务器作为我的 SFTP 服务器,我可以在其中创建经过身份验证的用户以 sftp 进入我的服务器。对于使用 s3fs 的每个用户,我已将 s3 存储桶安装到位于 /mnt/buckets/{username} 位置的服务器上。读取和写入 /mnt/buckets/{username} 目录可以按预期使用 s3。

我的 sshd_config 有以下内容。

ChrootDirectory /mnt/buckets/%u
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp

当 SFTP-ing 我得到以下响应

...
debug1: Authentication succeeded (publickey).
Authenticated to ec2-54-173-113-164.compute-1.amazonaws.com ([54.173.113.164]:22).
debug2: fd 5 setting O_NONBLOCK
debug3: fd 6 is O_NONBLOCK
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
Write failed: Broken pipe
Connection closed

挂载的存储桶具有这些权限。

/home/ubuntu# ls -l /mnt/buckets/
total 1
drwxrwxrwx 1 root root 0 Jan  1  1970 sftptester

当我将 Chroot 目录更改为 /mnt/buckets 时,我能够登录到 sftp 服务器以及读取和写入 s3 挂载的存储桶

我可以将用户 chroot 到已安装的 s3 存储桶中吗?

(另外,如果有任何工具已经具有此功能,我也会有兴趣了解它们)

4

1 回答 1

8

问题可能是在挂载文件夹中显示为用户目录的 S3“存储桶文件夹”没有 SFTP 用户读取它们的正确权限。

尝试将此添加到您的 S3FS 执行-o umask=022中。这将为您的 SFTP 用户文件夹添加以下权限:drwxr-xr-x

示例: sudo s3fs bucket-name /mount/folder/ -o iam_role=role_name -o allow_other -o stat_cache_expire=10 -o enable_noobj_cache -o enable_content_md5 -o umask=022

  • -o allow_other并且-o umask=022都需要我来完成这项工作。
于 2016-05-17T03:06:29.657 回答