curl - Download AWS S3 file from EC2 instance -


i've script download file aws s3 , works separate server outside of aws. when put script on ec2 instance , tried returns error "signaturedoesnotmatch - request signature calculated not match signature provided. check key , signing method."

but works on other server. ec2 on same region s3 host. i'm guessing has host. tried these host/url returns same error.

anyone able download s3 files ec2 curl? need use curl. please answer if know how through curl. thanks.

https://s3-ap-southeast-1.amazonaws.com/$bucket/$file

https://s3.amazonaws.com/$bucket/$file

https://$bucket.s3-ap-southeast-1.amazonaws.com/$file

https://$bucket.s3.amazonaws.com/$file

#!/bin/sh file="file-name" bucket="bucket-name" resource="/${bucket}/${file}" contenttype="application/x-compressed-tar" datevalue="`date +'%a, %d %b %y %h:%m:%s %z'`" stringtosign="get\n\n${contenttype}\n${datevalue}\n${resource}" s3key="xxxxxxxxxxxxxxxxxx" s3secret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" signature=$(echo -en "${stringtosign}" | openssl sha1 -hmac "${s3secret}" -binary | base64) curl -h "host: s3-ap-southeast-1.amazonaws.com" \  -h "date: $datevalue" \  -h "content-type: $contenttype" \  -h "authorization: aws ${s3key}:${signature}" \  https://s3-ap-southeast-1.amazonaws.com/$bucket/$file -o $file 

rather writing curl command, consider using aws command-line interface (cli).

it has aws s3 cp command can copy content to/from amazon s3 buckets (and between buckets).


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -