Skip to main content

S3cmd

Last update:

S3cmd is a command-line interface for services that support the Amazon S3 HTTP API (S3 API).

Configure S3cmd

  1. Configure access to S3.
  2. Install the client.
  3. Create an S3cmd configuration.

1. Configure access to S3

Access can be configured by the Account Owner or a user with the iam.admin role.

  1. Create a service user with a role with S3 access. If you use a service user with the s3.user, object_storage_user, or s3.bucket.user role, an access policy must be configured for the bucket, and its rules must allow access to this user.
  2. Issue an S3 key to the user.

2. Install the client

Download and install the client from GitHub S3cmd.

3. Create an s3cmd configuration

  1. Open the terminal.

  2. Open the configuration mode:

    s3cmd --configure
  3. Enter Access Key — the value of the Access key field from the S3 key.

  4. Enter Secret Key — the value of the Secret key field from your S3 key.

  5. Enter Default Region — the pool.

  6. Enter S3 Endpoint — the S3 API domain. The domain depends on the pool where your S3 is located.

  7. Enter the DNS-style bucket+hostname:port template for accessing a bucket — the S3 API domain. The domain depends on the pool where your S3 is located. The settings will be saved in the ~/.s3cfg file:

    [default]
    access_key = <access_key>
    secret_key = <secret_key>
    bucket_location = <pool>
    host_base = <s3_domain>
    host_bucket = <s3_domain>

Working with S3cmd

All commands can be found in the Usage section of the S3cmd documentation.

Create a bucket

  1. Open the terminal.

  2. Create a bucket:

    s3cmd mb s3://<bucket_name>

    Specify <bucket_name> — the name of the new bucket.

View the list of objects

  1. Open the terminal.

  2. View the list of objects:

    s3cmd ls s3://<bucket_name>

    Specify <bucket_name> — the name of the bucket.

Upload an object

  1. Open the terminal.

  2. Upload an object:

    s3cmd put <path> s3://<bucket_name>/<prefix>

    Specify:

    • <path> — path to the file in the local directory;
    • <bucket_name> — bucket name;
    • <prefix> — optional: the prefix to which the object will be uploaded.

Remove an object

  1. Open the terminal.

  2. Remove an object:

    s3cmd rm s3://<bucket_name>/<object_name>

    Specify:

    • <bucket_name> — bucket name;
    • <object_name> — the name of the object.