git clone S3错误:403禁止 [英] git clone S3 error: 403 Forbidden
问题描述
我希望能够将git存储库同步到AWS S3进行备份。此外,我希望公众能够 git clone
我的备份。 我的步骤为:
s3cmd mb s3:// lktesting
git update-server-info
s3cmd -P sync .git / s3:// lktesting
s3cmd ws-create s3:/ / lktesting
s3cmd ws-info s3:// lktesting
我以为这用于工作,但现在我得到:
git clone http://lktesting.s3-website-ap-southeast-1.amazonaws。 com /
克隆到'lktesting.s3-website-ap-southeast-1.amazonaws.com'...
错误:请求的URL返回错误:403 Forbidden(curl_result = 22,http_code = 403 ,sha1 = bf866b95d9517ea38e213740cead5cf1c313f5aa)
检查连通性...完成。
有谁知道我缺少什么?
显然,亚马逊如果您向所有人授予列表权限,S3存储桶将仅返回404代码:我如何有一个S3存储桶返回404(而不是403)的存储桶中不存在的关键/
更新:您可以使用AWS CLI为 put-bucket-acl from s3api。
在S3存储桶中托管可克隆git存储库的完整命令序列:
B UCKET = my-bucket-name
#安装
aws s3 mb s3:// $ BUCKET
aws s3api put-bucket-acl --bucket $ BUCKET --acl public -read
#Sync
git update-server-info
aws s3 sync --acl public-read .git s3:// $ BUCKET
#克隆
git克隆https://$BUCKET.s3.amazonaws.com
I want to be able to sync git repositories to AWS S3 for backups. Furthermore I want the public to be able to git clone
my backups. My steps were:
s3cmd mb s3://lktesting
git update-server-info
s3cmd -P sync .git/ s3://lktesting
s3cmd ws-create s3://lktesting
s3cmd ws-info s3://lktesting
I thought this used to work, but now I get:
git clone http://lktesting.s3-website-ap-southeast-1.amazonaws.com/
Cloning into 'lktesting.s3-website-ap-southeast-1.amazonaws.com'...
error: The requested URL returned error: 403 Forbidden (curl_result = 22, http_code = 403, sha1 = bf866b95d9517ea38e213740cead5cf1c313f5aa)
Checking connectivity... done.
Does anyone know what I am missing?
Git objects under .git
may exists as single files or inside git packs. The Git dumb HTTP protocol will try to fetch an object as a single file, and only if this fails with "404 Not found", it will look for a pack.
Apparently, an Amazon S3 bucket will only return the 404 code if you give the "List" permission to everyone: How do I have an S3 bucket return 404 (instead of 403) for a key that does not exist in the bucket/
Update: You can assign the necessary permission using AWS CLI with put-bucket-acl from s3api.
Complete sequence of commands to host a clonable git repository in an S3 bucket:
BUCKET=my-bucket-name
# Setup
aws s3 mb s3://$BUCKET
aws s3api put-bucket-acl --bucket $BUCKET --acl public-read
# Sync
git update-server-info
aws s3 sync --acl public-read .git s3://$BUCKET
# Clone
git clone https://$BUCKET.s3.amazonaws.com
这篇关于git clone S3错误:403禁止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!