Skip to content

Instantly share code, notes, and snippets.

@justinlund
Created February 20, 2015 22:09
Show Gist options
  • Save justinlund/e82f929d0a187e1983c7 to your computer and use it in GitHub Desktop.
Save justinlund/e82f929d0a187e1983c7 to your computer and use it in GitHub Desktop.
Quick script to demonstrate authenticating a request to download a private object from DreamObjects
#! /usr/bin/env bash
# Basic shell script to download a private object
# from DreamHost DreamObjects
file=$1
bucket="My_Bucket"
resource="/${bucket}/${file}"
dateValue=`date -Ru`
stringToSign="GET\n\n\n${dateValue}\n${resource}"
echo ${stringToSign}
s3Key="My_Access_Key"
s3Secret="My_Secret_Key"
echo "Retrieving From DreamObjects"
signature=`echo -en ${stringToSign} | openssl sha1 -hmac ${s3Secret} -binary | base64`
curl -vv -X GET \
-H "Host: ${bucket}.objects.dreamhost.com" \
-H "Date: ${dateValue}" \
-H "Authorization: AWS ${s3Key}:${signature}" \
${bucket}.objects.dreamhost.com/${file} -o ${file}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment