Skip to content

Instantly share code, notes, and snippets.

@pandeybk
Created May 26, 2016 15:00
Show Gist options
  • Save pandeybk/077ade4844c8fb114ec8f073a9a5e3e6 to your computer and use it in GitHub Desktop.
Save pandeybk/077ade4844c8fb114ec8f073a9a5e3e6 to your computer and use it in GitHub Desktop.
file=id_rsa.pub
bucket=com.dgmates.public.bucket
resource="/${bucket}/${file}"
contentType="text/plain"
dateValue="$(LC_ALL=C date -u +"%a, %d %b %Y %X %z")"
stringToSign="PUT\n\n${contentType}\n${dateValue}\n${resource}"
s3Key=<AWS_ACCESS_KEY_ID>
s3Secret=<AWS_ACCESS_KEY_SECRET>
signature=`echo -en ${stringToSign} | openssl sha1 -hmac ${s3Secret} -binary | base64`
curl -k -X PUT -T "${file}" \
-H "Host: ${bucket}.s3.amazonaws.com" \
-H "Date: ${dateValue}" \
-H "Content-Type: ${contentType}" \
-H "Authorization: AWS ${s3Key}:${signature}" \
https://${bucket}.s3.amazonaws.com/${file}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment