transfer.sh: a simple file sharing service
A friend of mine introduced me to transfer.sh more than a year ago. transfer.sh is a simple and free file transfer service that plays along with Linux very well.
Here's some notes on how I use it:
For this example, we'll download the Mozilla Firefox Source code. Then we'll encrypt it and upload it to transfer.sh to demonstrate it's usage.
1. Download the firefox source code:
cd /tmp
curl -LO https://archive.mozilla.org/pub/firefox/releases/54.0/source/firefox-54.0.source.tar.xz
2. Set a variable for the file you want to encrypt:
file=/tmp/firefox-54.0.source.tar.xz
3. Set another variable with the password you're going to use - in this example I'm creating a random 16 character-long password using OpenSSL:
password=`openssl rand -hex 16`
4. Encrypt the file using OpenSSL:
openssl aes-256-cbc -a -salt -in $file -out $file.enc -k $password
5. Upload to transfer.sh and store the result in the $upload variable
# Note that by using the `"Max-Days: 1"` header, the file will live in transfer.sh only for one day.
upload=`curl -H "Max-Days: 1" --upload-file $file.enc https://transfer.sh`
6. Print out the upload url and the password:
printf "url=$upload\npassword=$password\n"
Example output:
url=https://transfer.sh/iX4rT/firefox-54.0.source.tar.xz.enc
password=ee0ebdbe9a78da56ceab98d0a7615739
7. Or optionally, store them for later:
printf "url=$upload\npassword=$password\n" >> ~/uploaded-stuff.txt
To download the file:
1. Set a variable with your URL and one with your password (if not already set):
url=https://transfer.sh/iX4rT/firefox-54.0.source.tar.xz.enc
password=ee0ebdbe9a78da56ceab98d0a7615739
2. Download and decrypt:
cd /tmp
curl -LO $url
openssl aes-256-cbc -d -a -in `basename "$url"` -out `basename --suffix=".enc" "$url"` -k $password
Done!
Alternatively: Hate OpenSSL with a passion ? Use ccrypt:
1. Install the EPEL repository and use that to install ccrypt:
yum -y install epel-release && yum -y install ccrypt
2. Encrypt your file using ccrypt:
ccencrypt -K superpassword firefox-54.0.source.tar.xz
3. Decrypt it:
ccdecrypt -K superpassword firefox-54.0.source.tar.xz.cpt
Sources:
- SuperUser - How to use password argument in via command line to openssl for decryption
- Tombuntu - Simple File Encryption with OpenSSL
- How-To Geek - 10 Ways to Generate a Random Password from the Command Line
- Tecmint.com - 7 Tools to Encrypt/Decrypt and Password Protect Files in Linux
- Peter Selinger - ccrypt
- transfer.sh - Easy file sharing from the command line