s3cmd
is an excellent tool for interacting with S3-compatible storage solutions (Amazon S3, Backblaze B2, Linode Object Storage, etc.) via the command line.
I personally find it easier to use and more intuitive than the aws
equivalent.
Install s3cmd
The tool can be installed (on a Mac) via Homebrew:
brew install s3cmd
Configure s3cmd
The tool comes with a --configure
command in order to create a valid configuration file.
However, I need to deal with several storage accounts at any one time (for various things), and so it is useful for me to have separate profiles.
I keep these in my home directory. For example, my “personal” config file (~/.s3personal
) looks like this (for Linode Object Storage):
[personal]
access_key = CHANGETHIS
secret_key = CHANGETHIS
host_base = eu-central-1.linodeobjects.com
host_bucket = %(bucket)s.eu-central-1.linodeobjects.com
The access_key
and secret_key
can be provided by your storage provider.
You can create as many of these config files as required. I (currently) can’t find a way to keep them nicely in one file, but there may be one.
Using the profiles
The profiles can be used by including a -c
flag in your calls to s3cmd
.
For example, to use my personal profile to upload to a bucket I use:
s3cmd -c ~/.s3personal put FILE.png s3://BUCKET/path/FILE.png