The following shell script can be used to download a file from secured Amazon s3 bucket over https.
#!/bin/sh
file=path/to/file/in/the/bucket
bucket=bucket-name
s3Key=XXXXXXXXXXXXXXXXXX
s3Secret=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
###
resource="/${bucket}/${file}"
dateValue="`date +'%a, %d %b %Y %H:%M:%S %z'`"
stringToSign="GET\n\n\n\nx-amz-date:${dateValue}\n${resource}"
signature=`/bin/echo -en "$stringToSign" | openssl sha1 -hmac ${s3Secret} -binary | base64`
wget --header="Host: ${bucket}.s3.amazonaws.com" \
--header="x-amz-date: ${dateValue}" \
--header="Authorization: AWS ${s3Key}:${signature}" \
https://${bucket}.s3.amazonaws.com/${file}
Resources:
No comments:
Post a Comment