Search code examples
ubuntuencryptionamazon-s3s3cmd

Unable to use encrypt option on s3cmd


I have two simple scripts to upload and download some code to and from S3 on Amazon web services:

#####Upload Script
zip -r file.zip www
s3cmd del s3://mybucket/file.zip --encrypt
s3cmd put file.zip s3://mybucket --encrypt
rm -rf file.zip

#####Download Script
rm -rf /home/ubuntu/www/*
s3cmd sync s3://mybucket/file.zip /home/ubuntu/ --encrypt
unzip -u /home/ubuntu/file.zip -d /home/ubuntu/
rm -rf /home/ubuntu/file.zip

However these scripts only work when I don't use the --encrypt option. The resulting file has 11MB without encrypt and it unzips just fine, and 9MB using encrypt but gives me an error when I try to unzip it. How do I decrypt files from S3 since there is no --decrypt option and using --encrypt on the download also didn't worked?

I configured s3cmd correctly with encryption password, and it passed the config test. Here goes the error before anybody asks:

Archive:  /home/ubuntu/file2.zip
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
note:  /home/ubuntu/file2.zip may be a plain executable, not an archive
unzip:  cannot find zipfile directory in one of /home/ubuntu/file2.zip or
        /home/ubuntu/file2.zip.zip, and cannot find /home/ubuntu/file2.zip.ZIP, period.

Solution

  • Encryption appears to be broken in current upstream master branch HEAD 81e3842f7afb. You are best off encrypting, and the putting the encrypted file, directly. Certainly --encrypt with the [sync] command does not work.