

Encrypting data with S3cmd – DreamHost Knowledge Base
source link: https://help.dreamhost.com/hc/en-us/articles/360022340471-Encrypting-data-with-S3cmd
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Encrypting data with S3cmd
How to encrypt your data
S3cmd can encrypt your data while uploading to DreamObjects. To use this functionality, you must first configure your .s3cfg file as shown in this article:
Configuring your .s3cfg file
Open the file in your user's directory.
[server]$ nano ~/.s3cfg
Add the following lines so you can use encryption. Make sure to create your own password for gpg_passphrase:
check_ssl_certificate = True check_ssl_hostname = True gpg_command = /usr/bin/gpg gpg_decrypt = %(gpg_command)s -d --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s gpg_encrypt = %(gpg_command)s -c --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s gpg_passphrase = yourpassword
Your configuration is now set up to encrypt data.
Encrypting data while uploading
To encrypt your data while uploading, use the -e flag. In the following example, bucket-name is the name of the bucket you're uploading content in to. textfile.txt is the name of the single file you're uploading:
[server]$ s3cmd -e put testfile.txt s3://bucket-name upload: '/tmp/tmpfile-zFGwbLHMVEINdHh3615n' -> 's3://bucket-name/testfile.txt' [1 of 1] 63 of 63 100% in 0s 129.96 B/s done
To confirm it is encrypted, navigate to the DreamObjects page. Click the View Objects button under your username. A prompt opens for you to view objects in your bucket.
Click the object, copy the URL, and then paste it into a browser.
You'll see the data in the file is encrypted.
Decrypting a file
When you use s3cmd to download an encrypted file, it's automatically decrypted for you:
[server]$ s3cmd get s3://bucket-name/encrypted-file.txt download: 's3://bucket-name/encrypted-file.txt' -> './encrypted-file.txt' [1 of 1] 70 of 70 100% in 0s 323.19 B/s done
If you read the contents of the file, you'll see it's no longer encrypted:
[server]$ cat encrypted-file.txt Testing a file
Signing an S3 URL to provide limited public access
You can manually set an expiration date for a file to be accessed. To do this, you must first convert the date into a Unix Epoch timestamp.
- Decide on the date you wish to allow the URL to be signed/accessed until.
- Visit Epoch Converter to convert your date to an Epoch Timestamp. It will look like a string of numbers. For example: 1540232086
- Run the following command to sign the URL until this timestamp. (Make sure to change the bucket name and file name to your actual information.)
[server]$ s3cmd signurl s3://my_bucket/my_file.png 1540232086 http://my-bucket.objects-us-east-1.dream.io/my_file.png?AWSAccessKeyId=DHDPTCQ3WFGHPSS5FAXG&Expires=1540232086&Signature=9nf8f9kG%2FqDa76rmET4R%2FpbtaGM%3D
- This outputs the signed URL. You can now share this URL so anyone can access that file until the date you have specified.
You can also sign it for 1 week using this format:
[server]$ s3cmd signurl s3://my_bucket/my_file.png $(echo "`date +%s` + 3600 * 24 * 7" | bc)
Did this article answer your questions?
Recommend
-
11
php.ini overview If you find yourself in a situation that requires changes to your site, and your developer isn't available to help, DreamHost's skilled support team may be able to assist y...
-
10
The following provides information to help you prepare your website for Debian Buster. What is changing? VPS servers on both Ubuntu Precise and Ubuntu Trusty are being upgraded to Debian 10 (aka Debian Buster). The follo...
-
4
The following provides information to help you prepare your website for Debian Stretch. What is changing? Any new private server purchased after March 9th, 2020 runs the operating system Debian Stretch. The former operat...
-
13
The following provides information to help you prepare your site for the Ubuntu upgrade from Trusty Tahr to version 18.04.1 LTS (aka Bionic). What to expect DreamHost will contact you via email in advance of the upgrade....
-
10
DreamPress non-profit discount Overview The following information applies to DreamPress plans only. For more information on DreamHost's non-profit program for Shared Hosting...
-
7
Overview DreamHost offers Cloudflare plans on any hosting plan. You can find more information in the Cloudflare overview article. However,...
-
10
How do I add DreamPress to a new domain? Overview The following describes how to add DreamPress to a new domain at DreamHost. If you already have an existing
-
12
How to sign up for a DreamPress account Overview This article describes how to sign up for a new DreamPress hosting plan. This article is for new customers who wish to open an acco...
-
15
DreamPress plans and pricing Overview DreamPress offers several types of payment plans depending on your needs. Payment cycle — Select either an annual pre-...
-
12
How do I upgrade a WordPress site to DreamPress? Overview You can easily transfer any domain to DreamPress that is currently using WordPress as a
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK