ThorneLabs

Use the OpenStack swift Command with Rackspace Cloud Files

• Updated March 17, 2019


Rackspace Cloud Files is, and has always been, powered by OpenStack Swift. The easiest way to interface with Rackspace Cloud Files is through the web portal or third-party clients such as Cyberduck.

However, I am frequently logged into remote servers where I need to upload files to my Rackspace Cloud Files account. It would be a waste of time, and bandwidth, to download those files to my workstation then upload them through the web portal or a third-party client. Like any OpenStack project, the project’s shell command can be used instead.

The following post will describe how to use the swift command to connect to Rackspace Cloud Files using Swift’s v1.0 and v2.0 APIs.

To follow along you will need to have already created a Rackspace Public Cloud account.

Using Swift’s v1.0 API

Start by creating an openrc file on the server or workstation you want to use the swift command on:

export ST_AUTH=https://identity.api.rackspacecloud.com/v1.0
export ST_USER=<USERNAME>
export ST_KEY=<API KEY>

To obtain your API key:

  1. Log in to your Rackspace Public Cloud account as an administrative user
  2. Click Account: USERNAME in the upper right corner of the browser window and select User Management
  3. Click the Username for the particular user you want to use with Rackspace Cloud Files
  4. Click Show next to API Key under Login Details

Now, source the variables into your shell environment:

source openrc

Then, use the swift command.

Or, if you prefer, you can skip the creation of an openrc file and have your authentication in-line with the shell command:

swift -A https://identity.api.rackspacecloud.com/v1.0/ -U <USERNAME> -K <API KEY> list

Run swift --help to see all of the functions and additional variables available to you.

Using Swift’s v2.0 API

Take note, using Swift’s v2.0 API requires using your account’s password instead of an API key.

Like before, start by creating an openrc file on the server or workstation you want to use the swift command on:

export OS_AUTH_URL=https://identity.api.rackspacecloud.com/v2.0
export OS_USERNAME=<USERNAME>
export OS_PASSWORD=<PASSWORD>

Now, source the variables into your shell environment:

source openrc

Then, use the swift command.

Or, if you prefer, you can skip the creation of an openrc file and have your authentication in-line with the shell command:

swift -V 2.0 --os-auth-url=https://identity.api.rackspacecloud.com/v2.0 --os-username=<USERNAME> --os-password=<PASSWORD> list

Run swift --help to see all of the functions and additional variables available to you.

If needed, you can specify a region by adding the following to the openrc file:

export OS_REGION_NAME=<IAD | ORD | HKG | DFW | SYD>

Once the environment variable is added, re-source the file.

The same can be done in-line with the shell command by adding the following command line switch:

--os-region-name=<IAD | ORD | HKG | DFW | SYD>

References

If you found this post useful and would like to help support this site - and get something for yourself - sign up for any of the services listed below through the provided affiliate links. I will receive a referral payment from any of the services you sign-up for.

Get faster shipping and more with Amazon Prime: About to order something from Amazon but want to get more value out of the money you would normally pay for shipping? Sign-up for a free 30-day trial of Amazon Prime to get free two-day shipping, access to thousands of movies and TV shows, and more.

Thanks for reading and take care.