# Using S3 tools

A CrushMFT server answers tools that speak the protocol of Amazon S3. This page is for the people who connect such a tool. For the server's side, see [The S3 server](Ports-S3-Server.md).

## The four values every tool asks for

| The tool asks for | Enter |
|---|---|
| endpoint, "server", "custom URL" | the address of the server's web interface: `https://files.example.com` |
| access key | your user name, a tilde, and your password: `alex~PASSWORD` |
| secret key | your password |
| region | `us-east-1`, unless the administrator names another |

And two choices:

| Choice | Take |
|---|---|
| addressing style | **path style** (`https://server/bucket/key`), unless the administrator set up host names per bucket |
| bucket | usually one, named `bucket`: it is all of your folders. Some servers show each of your top folders as a bucket. List the buckets to see. |

## AWS command line

```
aws configure set aws_access_key_id 'alex~PASSWORD'
aws configure set aws_secret_access_key 'PASSWORD'
aws configure set region us-east-1

aws --endpoint-url https://files.example.com s3 ls
aws --endpoint-url https://files.example.com s3 ls s3://bucket/
aws --endpoint-url https://files.example.com s3 cp report.pdf s3://bucket/Incoming/
aws --endpoint-url https://files.example.com s3 sync ./out s3://bucket/Outgoing/
```

Listing, copying up and down, large uploads in parts, `sync`, `mv`, `rm`, and presigned links were run against the server with this tool when the S3 server was built.

## rclone

In `rclone.conf`:

```
[crush]
type = s3
provider = Other
endpoint = https://files.example.com
access_key_id = alex~PASSWORD
secret_access_key = PASSWORD
region = us-east-1
force_path_style = true
```

then `rclone ls crush:bucket`, `rclone copy ./out crush:bucket/Outgoing`.

## Cyberduck and others

Choose "Amazon S3" or "S3 (generic)", enter the server's address as the server, the access key and the secret key. If the program has a setting for path-style addressing, turn it on.

## curl

Current versions of curl can sign S3 requests by themselves:

```
curl --aws-sigv4 "aws:amz:us-east-1:s3" --user 'alex~PASSWORD:PASSWORD' https://files.example.com/
curl --aws-sigv4 "aws:amz:us-east-1:s3" --user 'alex~PASSWORD:PASSWORD' -T report.pdf https://files.example.com/bucket/Incoming/report.pdf
curl --aws-sigv4 "aws:amz:us-east-1:s3" --user 'alex~PASSWORD:PASSWORD' https://files.example.com/bucket/Incoming/report.pdf -o report.pdf
```

The first lists the buckets. On the test server it answered with one bucket, `bucket`; an upload answered `200`, a download gave the file back, and a delete answered `204`.

## Your password is in the access key

The access key holds your password in readable form. Treat the tool's configuration file like a password file: readable only by you, never in a repository, never in a ticket.

- Ask the administrator for an account made for the tool, with rights on just the folders it needs.
- When the password is changed, both values change.
- A password with a tilde in it confuses the split between name and password. Avoid `~` in passwords of accounts that use S3.

## What to expect

- "Folders" exist as on the server: a key `Incoming/report.pdf` is the file `report.pdf` in your folder `Incoming`. Folders that are missing are made on upload.
- A delete that leaves a folder empty may remove the folder too, as in S3.
- The ETag of a file is not its MD5. Tools that compare content by ETag fall back to size and date, which is what you want.
- Versions, access lists, tags and bucket policies are not there: the server answers such calls politely and does nothing.
- Your usual rights hold: a folder you may not write to in the web interface, you may not write to here.

## When it does not work

| What you see | Usually |
|---|---|
| `InvalidAccessKeyId`: "The user name or password in the access key (user~password) is not valid." | a typing mistake in the access key; no `~`; an expired password |
| `SignatureDoesNotMatch` | the secret key is not the password; a region the server does not call itself; the computer's clock is off by more than a few minutes |
| the tool looks for `bucket.files.example.com` | turn on path-style addressing |
| `AccessDenied` on a folder | your rights there; or S3 is not allowed for your account |
| `NoSuchKey` | the path. Upper and lower case count. |
