Connect to Amazon S3 Bucket from the Command Line in OS X

This process requires a couple of Unix tools installed, s3cmd and gpg (optional), s3cmd is the command line tool used to connect to Amazon S3 and gpg is an optional secure tool allowing data transfer to be encypted over HTTPS between you and Amazon.

This guide uses Homebrew to install the 2 required programs, this can also be done with MacPorts.

You will already need to have your Amazon S3 buckets set up and need to have Access ID and Secret Key ready to be pasted into the Terminal.

Install s3cmd

brew install s3cmd

Install gpg

brew install gpg

Configure s3cmd

s3cmd --configure

When prompted paste in your Access key, Secret key and encryption password, the encyption password has to be made by you. The path to gpg is:


Thats all you need to do.

Using the s3cmd Tool

To list all your buckets:

s3cmd ls

To list contents of a bucket:

s3cmd ls s3://mybucket

To get something from the bucket and move to your desktop:

s3cmd get s3://mybucket/my-needed-file.png ~/Desktop

And the reverse to put something to the bucket – using the –P flag to make it public:

s3cmd -P put ~/Desktop/my-file.png  s3://mybucket/

To delete a file:

s3cmd del s3://mybucket/my-file-to-delete.png

Check the man for more options

man s3cmd