【问题标题】:SFTP Chroot Users to Mounted S3 bucketSFTP Chroot 用户到挂载的 S3 存储桶
【发布时间】:2016-02-10 17:16:37
【问题描述】:

我正在尝试使用 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

挂载的bucket拥有这些权限。

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

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

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

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

【问题讨论】:

  • 我不知道使用 openssh 内置的 sftp 有多简单,但它可以与 proftpd+s3fs 一起按预期工作。 stackoverflow.com/a/23946418/1695906
  • 你解决过这个问题吗?

标签: amazon-web-services amazon-s3 amazon-ec2 sftp s3fs


【解决方案1】:

问题可能是在挂载文件夹中显示为用户目录的 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 才能完成这项工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-19
    • 2021-09-13
    • 2019-12-06
    • 1970-01-01
    • 2012-09-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多