|
| 1 | +#!/bin/bash |
| 2 | +#-------------------------------------------- |
| 3 | +# Name: SES SMTP CONVERTER |
| 4 | +# Author: Tomas Nevar ([email protected]) |
| 5 | +# Version: v1.0 |
| 6 | +# Date: 14/10/2014 (dd/mm/yy) |
| 7 | +# Licence: copyleft free software |
| 8 | +#-------------------------------------------- |
| 9 | +# |
| 10 | +# Many thanks to: |
| 11 | +# http://blog.celingest.com/en/2014/02/12/new-ses-endpoints-creating-ses-credentials-iam-users/ |
| 12 | + |
| 13 | +# Check for OpenSSL installation, exit if not present |
| 14 | +type openssl >/dev/null 2>&1 || { echo >&2 "I require OpenSSL, but it's not installed. Aborting."; exit 1; }; |
| 15 | + |
| 16 | +# If you want to provide the AWS keys below rather than supplying on a CLI, |
| 17 | +# you can do so and comment out everything in between dashes (#---) |
| 18 | +#IAMUSER=""; |
| 19 | +#IAMSECRET=""; |
| 20 | + |
| 21 | +#-------------------------------------------- |
| 22 | +IAMUSER="$1"; |
| 23 | +IAMSECRET="$2"; |
| 24 | + |
| 25 | +if [ "$#" -ne "2" ];then |
| 26 | + echo "Usage: ./ses-smtp-conv.sh <AWSAccessKeyID> <AWSSecretAccessKey>"; |
| 27 | + echo "Alternatively, you can put the AWS keys in the script."; |
| 28 | + exit 1 |
| 29 | +fi |
| 30 | +#-------------------------------------------- |
| 31 | + |
| 32 | +# You do not need to modify anything below this line |
| 33 | +MSG="SendRawEmail"; |
| 34 | +VerInBytes="2"; |
| 35 | +VerInBytes=$(printf \\$(printf '%03o' "$VerInBytes")); |
| 36 | + |
| 37 | +SignInBytes=$(echo -n "$MSG"|openssl dgst -sha256 -hmac "$IAMSECRET" -binary); |
| 38 | +SignAndVer=""$VerInBytes""$SignInBytes""; |
| 39 | +SmtpPass=$(echo -n "$SignAndVer"|base64); |
| 40 | + |
| 41 | +echo "SMTP User: ""$IAMUSER"; |
| 42 | +echo "SMTP Pass: ""$SmtpPass"; |
| 43 | + |
| 44 | +exit 0 |
0 commit comments