How to Use s3cmd with Vultr Object Storage

Updated on November 4, 2022
How to Use s3cmd with Vultr Object Storage header image

Introduction

s3cmd is a popular command-line tool for managing S3-compatible object storage.

Vultr Object Storage is a highly scalable solution for storing large quantities of files. Our architecture was designed from the ground up to provide high redundancy and data durability, and backed by blazing fast NVMe caching to make sure you have the best storage performance. Vultr Object Storage is compatible with a subset of the S3 API. See our compatibility matrix for details.

Prerequisites

You will need:

Set Default Configuration

The s3cmd configuration file, .s3cfg, is located in your home directory. It's a plain text file that defines the default options when you run commands. You can specify a different configuration file with the -c ~/path/to/config/file command-line option. To configure Vultr as the default provider, complete the steps below.

  1. Run s3cmd with the --configure option.

     $ s3cmd --configure
  2. Enter your access and secret keys. Find these values in your customer portal.

     Access Key: exampleNMWQSG599TB3A
     Secret Key: exampleCL2s4EgQRhnXafSBHCsjlsz1XVfJBeE4V
  3. Type Enter to accept the default region. Vultr ignores this value.

     Default Region [US]:
  4. Enter one of Vultr's object storage hostnames for the S3 Endpoint. For example, if you choose the New Jersey location, use ewr1.vultrobjects.com.

     S3 Endpoint [s3.amazonaws.com]: ewr1.vultrobjects.com

    Vultr's hostnames are:

    • Amsterdam: ams1.vultrobjects.com
    • New Jersey: ewr1.vultrobjects.com
    • Silicon Valley: sjc1.vultrobjects.com
    • Singapore: sgp1.vultrobjects.com
  5. Enter the DNS-style template. For example, if you choose the New Jersey location, use %(bucket)s.ewr1.vultrobjects.com.

     DNS-style bucket+hostname:port template for accessing a 
     bucket [%(bucket)s.s3.amazonaws.com]: %(bucket)s.ewr1.vultrobjects.com

    Vultr's DNS-style templates are:

    • Amsterdam: %(bucket)s.ams1.vultrobjects.com
    • New Jersey: %(bucket)s.ewr1.vultrobjects.com
    • Silicon Valley: %(bucket)s.sjc1.vultrobjects.com
    • Singapore: %(bucket)s.sgp1.vultrobjects.com
  6. Optional Encryption Password: GPG encryption protects objects while stored at Vultr. Setting this password does not automatically encrypt objects; it only makes the option available later. Linux users can usually accept the default path to GPG. macOS users may need to install GPG first, then locate the path with which gpg.

     Encryption password: example
     Path to GPG program [/usr/bin/gpg]:
  7. Enter Enter to use HTTPS protocol. Vultr Object Storage requires HTTPS.

     Use HTTPS protocol [Yes]:
  8. Optional: If your network requires an HTTP Proxy, enter that here. Otherwise press Enter.

     HTTP Proxy server name:
  9. Press Y + Enter to test the s3cmd configuration.

     Test access with supplied credentials? [Y/n] y
     Please wait, attempting to list all buckets...
     Success. Your access key and secret key worked fine :-)
  10. Press Y + Enter to save the .s3cfg file.

     Save settings? [y/N] y
     Configuration saved to '~/.s3cfg'

How to Use s3cmd

For comprehensive documentation, see the official documentation. These are some of the most commonly-used commands.

Make a bucket.

s3cmd mb s3://mybucket

Remove a bucket.

s3cmd rb s3://mybucket

List the buckets.

s3cmd ls

List the objects in the bucket.

s3cmd ls s3://mybucket

Delete all objects in a bucket.

s3cmd del --recursive --force s3://mybucket

Upload a file for private access.

s3cmd put photo.jpg s3://mybucket/photo.jpg

Upload a file for public access.

s3cmd put -P photo.jpg s3://mybucket/photo.jpg

Download a file.

s3cmd get s3://mybucket/photo.jpg

Delete a file.

s3cmd rm s3://mybucket/photo.jpg

Change file permission to public access.

s3cmd setacl s3://mybucket/photo.jpg --acl-public

Change file permission to private access.

s3cmd setacl s3://mybucket/photo.jpg --acl-private

Enable public directory listing for a bucket.

s3cmd setacl s3://mybucket/ --acl-public

Disable public directory listing for a bucket.

s3cmd setacl s3://mybucket/ --acl-private