index.md (3602B)
1 --- 2 title: "Simple, Secure File Transmission" 3 date: 2013-08-29T00:00:00+00:00 4 draft: false 5 canonical_url: https://www.viget.com/articles/simple-secure-file-transmission/ 6 --- 7 8 Often I need to send a file containing sensitive information, like a 9 database dump or a digital certificate, to a client or fellow developer. 10 It's difficult to know the correct level of paranoia to exhibit in 11 situations like these. Obviously, nobody's sitting in front of a 12 computer in a dark room, just *waiting* for me to leak the SSL 13 certificate for the staging Solr EC2 box. At the same time, I know there 14 are many people with access to my email, my Dropbox, my Basecamp posts, 15 and it would be irresponsible of me to rely on their collective good 16 faith to keep this information secure. 17 18 I've settled on a simple solution that doesn't inconvenience the sender 19 or receiver too terribly much (assuming they're both on modern, 20 Unix-compatible machines) while making things considerably more 21 difficult for any would-be eavesdroppers. Suppose I want to send an AWS 22 PEM certificate to [Chris](https://viget.com/about/team/cjones), 23 disregarding the fact that he's sitting maybe four feet from me right 24 now. Here's what I'd do: 25 26 ### Step 1: Encrypt with OpenSSL 27 28 I have a short shell script, `encrypt.sh`, that lives in my `~/.bin` 29 directory: 30 31 ```sh 32 #!/bin/sh 33 34 openssl aes-256-cbc -a -salt -pass "pass:$2" -in $1 -out $1.enc 35 36 echo "openssl aes-256-cbc -d -a -pass "pass:XXX" -in $1.enc -out $1" 37 ``` 38 39 This script takes two arguments: the file you want to encrypt and a 40 password (or, preferably, a [passphrase](https://xkcd.com/936/)). To 41 encrypt the certificate, I'd run: 42 43 ``` 44 > encrypt.sh production.pem \ 45 "I can get you a toe by 3 o'clock this afternoon." 46 ``` 47 48 The script creates an encrypted file, `production.pem.enc`, and outputs 49 instructions for decrypting it, but with the password blanked out. 50 51 ### Step 2: Send the encrypted file 52 53 From here, I'd move the encrypted file to my Dropbox public folder and 54 send Chris the generated link, as well as the output of `encrypt.sh`, 55 over IM: 56 57 {{<dither lSEsz5z.jpg "" "inline">}}Instant message thread where David Eisinger shares a Dropbox link and an OpenSSL command, and Chris Jones replies “got it” one minute later in the muted IM client window.{{</dither>}} 58 59 Once he acknowledges that he's received the file, I immediately delete 60 it. 61 62 ### Step 3: Send the password (via another channel) 63 64 Now I need to send Chris the password. Here's what I **don't** do: send 65 it to him over the same channel that I used to send the file itself. 66 Instead, I pull out my phone and send it to him as a text message: 67 68 {{<dither pQHZlkO.jpg "" "inline">}}Text exchange showing one friend confidently promising, “I can get you a toe by 3 o’clock this afternoon,” and the other dryly replying, “With nail polish?”{{</dither>}} 69 70 Now Chris has the file, instructions to decrypt it, and the passphrase, 71 so he's good to go. An attacker, meanwhile, would need access to both 72 his Google chat and iOS messages, or at least a sweet [\$5 73 wrench](http://xkcd.com/538/). (Friday is two-for-one XKCD day, in case 74 you missed the sign out front.) 75 76 ------------------------------------------------------------------------ 77 78 So that's what I've been doing when I have to send private files across 79 the network. I'm sure a security expert could find a hundred ways that 80 it's insufficient, but I hope said strawman expert would agree that this 81 is a much better approach than sending this information in the clear. 82 I'm curious what others do in these types of situations -- let me know 83 in the comments below.