When making an Amazon S3 request the awscli tool uses the current time on your server to sign the request being made to S3. On the server side AWS uses the current time to validate the request signature. To this end the Amazon S3 servers only allow for a variation of up to 15 minutes between UTC time on your server and theirs. Therefore if your server's clock is not set accuratley enough requests to S3 will error out with a RequestTimeTooSkewed error.

In order to fix this you can sync your server time with NTP servers. Here's how to install NTP and configure.

1) Install the NTP package for your OS distribution

apt-get install ntp (for Debian based distros)

yum install ntp (for Red Hat based distros)

2) Edit the /etc/ntp.conf file and set the following NTP servers
 
server 0.amazon.pool.ntp.org iburst
server 1.amazon.pool.ntp.org iburst
server 2.amazon.pool.ntp.org iburst
server 3.amazon.pool.ntp.org iburst

3) Restart the ntpd service

service ntpd restart

4) Now check the variance between the AWS S3 server's date and your own.

To get the date on your server (formatted similarly to the AWS date format) run the following command:

date -u +%a,\ %e\ %b\ %Y\ %T\ %Z


To make a generic HTTP request to S3 generating a response that has their date in it run the following command (parses out the date from the response):

curl http://s3.amazonaws.com -v 2>&1 | grep -E -i -w '< Date:' | awk '/<\sDate:\s/ { gsub(/<\sDate:\s/, \"\") }; { print }'

As long as the variance between the S3 date and your date is < 15 minutes you shouldn't encounter the RequestTimeTooSkewed error.

If you'd like do go above and beyond just checking the dates and actually make an S3 request from the command line to verify everything is working you can do so with the following set of commands:

export AWS_ACCESS_KEY_ID={YOUR-ACCESS-KEY}
export AWS_SECRET_ACCESS_KEY={YOUR-SECRET-KEY}
export AWS_DEFAULT_REGION={YOUR-AWS-REGION}
aws s3 ls s3://{YOUR-BUCKET}

If everything is configured correctly you should see a listing of the bucket contents.

🎉🎉🎉

We hope you find this helpful! If you need any further assistance, please contact us and we'll be more than glad to help you out. 

Did this answer your question?