s3cmd is a powerful command-line tool designed for managing S3-compatible object storage. This guide explains how to configure s3cmd to upload or download objects to/from your object storage buckets in Genesis Cloud.
In order to use s3cmd to upload or download your Objects, you should have already followed the steps here to create your Buckets.
Install s3cmd:
On Ubuntu:
If you are using Ubuntu, you can install s3cmd from the default repositories using apt:
sudo apt update && sudo apt install s3cmd |
On MacOS:
For macOS users, the easiest way to install s3cmd is through Homebrew:
brew install s3cmd |
If you want to verify s3cmd installation, you can do it by running:
s3cmd --version |
This command should return the version ofs3cmd
that you have installed, indicating that the installation was successful.
Initialize s3cmd Configuration for Genesis Cloud
To begin configuring s3cmd
, initiate the configuration process by running:
s3cmd --configure |
Below is a breakdown of each required field during the setup.
Authentication
Refer to our previous article for details on obtaining your Access Key and Secret Key. During the configuration process, when prompted for these keys, input the ones you generated for Genesis Cloud access.
Access Key: (Refer to the previous article for obtaining your Access Key)
Secret Key: (Refer to the previous article for obtaining your Secret Key)
Region & Endpoint
Default Region: set '
nord-no-krs-1'
as the default region when prompted.S3 Endpoint: When it comes to setting the S3 Endpoint, you can find the endpoint specific to their region directly in our UI and copy it from there. This information is essential for configuring
s3cmd
correctly.
Click on 'Object Storage' in the left-hand menu of the console dashboard.
Click on bucket of a specific region, in 'Bucket details' section, you will find 'S3 endpoint URL' for that region. Copy it and paste it in 'S3 Endpoint' field.
For Norway region, it is: 's3.nord-no-krs-1.genesiscloudusercontent.com'
DNS-style Bucket Access:
- To access your buckets, use the endpoint URL followed by '/%(bucket)' in the 'DNS-style bucket+hostname:port template for accessing a bucket' field. This format allows
s3cmd
to correctly resolve the full URL for bucket access. - For Norway region, it is: 's3.nord-no-krs-1.genesiscloudusercontent.com/%(bucket)'
Advanced Settings
Complete the setup by proceeding through the remaining prompts. The default settings should suffice for most users, but you can adjust as needed:
- Encryption Password: If you wish to encrypt your files, specify an encryption password.
- Path to GPG program: Enter '/usr/bin/gpg' or '
/opt/homebrew/bin/gpg'
or the correct path to your GPG program. - Use HTTPS Protocol: Set this to '
Yes'
for secure connections. - HTTP Proxy: If applicable, configure your proxy settings.
After completing these steps, your s3cmd
is configured for use with Genesis Cloud. You can now begin managing your object storage with s3cmd
commands.
Example of Configuration:
New settings:
|
Upload Your Objects to a Bucket
List Buckets: In order to upload Objects to your Bucket, first list all the Buckets you have using
s3cmd ls |
and get the name of the Bucket where you want to upload the file.
Upload a File: Use the s3cmd put command to upload your file to the bucket as follows
s3cmd put FILENAME s3://BUCKETNAME/PATH/TO/DESTINATION |
Important: Replace FILENAME with the name of the file you are uploading, BUCKETNAME with the name of your Bucket, and PATH/TO/DESTINATION with the desired path within your bucket where the file will be stored. If you do not specify a path, the file will be placed in the bucket's root directory.
Example:
Upload to root: To upload a file named example.txt to the root of a bucket named my-genesis-cloud-bucket, you would use
s3cmd put example.txt s3://my-genesis-cloud-bucket/
- Upload to folder: If you want to upload the file to a folder named docs within the bucket, you would use:s3cmd put example.txt s3://my-genesis-cloud-bucket/docs/
s3cmd
will show a progress indicator during the upload and notify you once the file has been successfully uploaded.
Download Your Objects from a Bucket
Download a file: Use the s3cmd get
command to download your file from the bucket as follows:
s3cmd get s3://BUCKETNAME/PATH/TO/FILE/FILENAME LOCALFILEPATH |
Important: Replace BUCKETNAME with the name of your Genesis Cloud bucket, PATH/TO/FILE/FILENAME with the path and filename of the file you wish to download, LOCALFILEPATH with the path where you want to save the file locally. If you only specify a filename, s3cmd will save the file in the current directory.
Example:
To download a file named example.txt
from a folder named docs
in a bucket called my-genesis-cloud-bucket
to your current directory, you would use:
s3cmd get s3://my-genesis-cloud-bucket/docs/example.txt ./example.txt |
This command tells s3cmd to download example.txt from your specified bucket and folder and save it as example.txt in your current directory.
s3cmd will show a progress indicator during the download and notify you once the file has been successfully downloaded.