# 使用 AWS CLI 访问 S3：连接、复制、同步

https://www.trecloud.com.tr/zh/knowledgebase/article/aws-cli-ile-s3-kullanimi

AWS CLI 是从命令行向 S3 兼容存储发送文件的常用方式。本文介绍如何用 AWS CLI v2 连接 TreCloud S3 存储桶。

![使用 AWS CLI 访问 S3：连接、复制、同步](https://www.trecloud.com.tr/resources/uploads/articles/2026-11-24/aws-cli-ile-s3-kullanimi.jpg)

## 创建配置文件

运行 `aws configure --profile trecloud`，填入 ACCESS_KEY、SECRET_KEY 和面板“Bölge”中的区域值。然后设置端点和 path-style：

```
aws configure set s3.addressing_style path --profile trecloud
aws configure set endpoint_url https://s3.trecloud.com.tr --profile trecloud
```

## 常用命令

使用 `aws s3 ls`、`aws s3 cp` 和 `aws s3 sync`（先加 `--dryrun`）。备份时不要使用 `--delete`：源目录中缺失的文件也会从存储桶删除。如遇校验和错误，将 AWS_REQUEST_CHECKSUM_CALCULATION 和 AWS_RESPONSE_CHECKSUM_VALIDATION 设为 when_required。

## 常见问题

为什么上传时出现 AccessDenied？通常是使用了只读密钥。上传需要写入密钥。 配额满了怎么办？写入会停止，读取照常。删除不需要的文件或升级套餐。

## 相关页面

- [S3 对象存储套餐](https://www.trecloud.com.tr/nesne-depolama)
- [S3 访问信息和密钥](https://www.trecloud.com.tr/bilgi-bankasi/makale/s3-erisim-bilgileri-ve-anahtarlar)

作者：TreCloud 团队 · TRE Teknoloji · 2026年10月7日
