How do I used s3cmd unattended?

I need to push a file up to Linode object storage using s3cmd (if there's an alternative app, please let me know). This will be done via a shell script, and must be 100% unattended, so I cannot manually create an auth session and enter my key/secret etc. All credentials and access parameters must be supplied as command line args.

I'm trying

AWS_REGION=eu-central-1
AWS_BUCKET=mybucket
AWS_ACCESS_KEY_ID=mykey
AWS_SECRET_ACCESS_KEY=mysecret
s3cmd sync test.txt s3://mybucket.eu-central-1.linodeobjects.com/test.txt

I've also tried using

s3cmd … --access_key=ACCESS_KEY --secret_key=SECRET_KEY

I get

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

I assume s3cmd is trying to authenticate up against AWS?

4 Replies

Did you set the website_endpoint in your .s3cfg?
It should look something like

website_endpoint = http://%(bucket)s.website-eu-central-1.linodeobjects.com

This is mentioned in the guide on hosting a static site

No, I cannot set anything up on the system beforehand. All I can do is install s3cmd, there is no .s3cfg on my system and never will be, it's completely stateless. I can push to AWS with the example I'm using, I would like to be able to do the same with Linode.

Looks like the option you need (from the s3cmd docs) is

--host=HOSTNAME

E.g.

s3cmd … --host=eu-central-1.linodeobjects.com --access_key=ACCESS_KEY --secret_key=SECRET_KEY

You might also need to pass “--host-bucket=” to get correct URLs.

Thanks Andysh, that did it.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct