s3fs 在 $HOME/.aws 中使用凭据和配置,而不是 /passwd-s3fs 文件

s3fs use credentials and config within $HOME/.aws as opposed to a /passwd-s3fs file

我在看the readme of s3fs repo

我想使用此工具在本地安装 S3 目录。自述文件说:

s3fs supports the standard AWS credentials file stored in ${HOME}/.aws/credentials. Alternatively, s3fs supports a custom passwd file.

后续示例似乎都使用自定义密码文件而不是 ~/.aws 中的凭据。我想在 ~/.aws.

中使用凭据

我的 .aws 凭据和配置文件如下所示:

~/.aws/credentials:

[work]
aws_access_key_id=123abc
aws_secret_access_key=mykeyhere
aws_s3_endpoint=s3.us-south.cloud-object-storage.appdomain.cloud

~/.aws/config:

[work]
region=us-south

我第一次尝试 'hello world' / 运行 s3fs。提供的自述文件示例:

Run s3fs with an existing bucket mybucket and directory /path/to/mountpoint:

s3fs mybucket /path/to/mountpoint -o passwd_file=${HOME}/.passwd-s3fs

我没有 passwd 文件,我想改用 .aws 中的凭据,但不知道该怎么做。尝试过:

只是放弃 -o passwd 选项并希望它会默认:

s3fs companyname-us-south-analytics-ml-models /home/doug/Documents/Projects/companyname/Projects/companynameS3
s3fs: could not determine how to establish security credentials.

然后我尝试根据示例添加 aws 凭证文件:

s3fs companyname-us-south-analytics-ml-models /home/doug/Documents/Projects/companyname/Projects/companynameS3 -o passwd_file=${HOME}/.aws/credentials
s3fs: could not determine how to establish security credentials.

然后我尝试根据我的 aws 配置文件引用 'work'(在此处抓住分支)

s3fs companyname-us-south-analytics-ml-models /home/doug/Documents/Projects/companyname/Projects/companynameS3 -o work
    s3fs: could not determine how to establish security credentials.

我查看了 man s3fs 并发现了一些正在验证中的信息:

AUTHENTICATION
       The s3fs password file has this format (use this format if you have only one set of creden‐
       tials):
           accessKeyId:secretAccessKey

       If you have more than one set of credentials, this syntax is also recognized:
           bucketName:accessKeyId:secretAccessKey

       Password files can be stored in two locations:
            /etc/passwd-s3fs     [0640]
            $HOME/.passwd-s3fs   [0600]

我找不到任何有关使用 ~/.aws 中的设置进行身份验证的信息。

如何使用 .aws 中的凭据设置 s3fs?

如果您想使用 ${HOME}/.aws/credentials 中的“工作”配置文件,则需要添加 -o profile=work 选项。