s3cmd icon indicating copy to clipboard operation
s3cmd copied to clipboard

--host-bucket help message is unclear

Open tashrifbillah opened this issue 3 years ago • 2 comments

For our s3 storage, I had to define both --host and --host-bucket parameters the same:

[me@my-cluster s3cmd-2.2.0]$ s3cmd --access_key my-key --secret_key secret-key --host my.host.com:9000 \
--host-bucket my.host.com:9000 --no-check-certificate ls s3://test1

2022-02-19 16:49         6647  s3://test1/date-row.json
2022-02-20 00:35         1175  s3://test1/duplicity-full-signatures.20220220T003532Z.sigtar.gz

If I do not define --host-bucket, s3cmd thinks the bucket is hosted at AWS s3 storage:

[me@my-cluster s3cmd-2.2.0]$ s3cmd --access_key my-key --secret_key secret-key --host my.host.com:9000 \
 --no-check-certificate ls s3://test1

ERROR: S3 error: 403 (InvalidAccessKeyId): The AWS Access Key Id you provided does not exist in our records.

(My access key is correct for my s3 storage. It does not apply to AWS s3 storage)


Given the above, this help message is unclear:

s3cmd --help ... --host=HOSTNAME HOSTNAME:PORT for S3 endpoint (default: s3.amazonaws.com, alternatives such as s3-eu- west-1.amazonaws.com). You should also set --host- bucket.

--host-bucket=HOST_BUCKET DNS-style bucket+hostname:port template for accessing a bucket (default: %(bucket)s.s3.amazonaws.com) ...

What could be a better message to indicate the above need?

tashrifbillah avatar Feb 21 '22 19:02 tashrifbillah

From debug output, it appears that without the --host-bucket argument, s3cmd assumes the host is the official host:

DEBUG: ===== SUCCESS Inner request to determine the bucket region ('us-east-1') =====
DEBUG: Using signature v4
DEBUG: get_hostname(test1): test1.s3.amazonaws.com
DEBUG: canonical_headers = host:test1.s3.amazonaws.com

as opposed to:

DEBUG: ===== SUCCESS Inner request to determine the bucket region ('us-east-1') =====
DEBUG: Using signature v4
DEBUG: get_hostname(test1): my.host.com:9000
DEBUG: canonical_headers = host:my.host.com:9000

tashrifbillah avatar Feb 21 '22 20:02 tashrifbillah

@tashrifbillah Thank you for your report. In fact, most people have the host and host-bucket set inside they s3cfg file, so the problem is not common.

What do you think would be a good resolution for this?

You think that adding the following to the help would help? << You might also have to set --host. >>

fviard avatar Jul 02 '22 11:07 fviard