
Using GPG to Encrypt Your Data - maxt
https://www.nas.nasa.gov/hecc/support/kb/using-gpg-to-encrypt-your-data_242.html
======
jph
For GPG symmetric encryption, the kind the article describes, here are the
best options I've found for my typical case:

    
    
       gpg --symmetric \
       --cipher-algo aes256 \
       --digest-algo sha256 \
       --cert-digest-algo sha256 \
       --compress-algo none -z 0 \
       --quiet --no-greeting \
       --no-use-agent "$@"
    

I keep this command here:

    
    
        https://github.com/SixArm/gpg-encrypt
    

The options are chosen to balance tradeoffs of convenience, strength, and
portability.

~~~
txutxu
Regarding the code...

    
    
        set -euf
        onecmd --args "$@"
    

The set -u is unneeded, as there are no code variables involved.

The set -e is not needed, as there is only one command, and the script will
return the exit status of such command. Always. And will exit after that
command. Always.

The set -f, will disable globbing, which I'm not sure it's what you want, when
using a simple wrapper passing "$@" as filenames to gpg...

~~~
nothrabannosir
I disagree. set -eu should be at the top of every bash script.

This is the classic braceless if-guard mistake; leave it out today because you
don't need it, forget, add something tomorrow and it breaks.

~~~
switch007
You can over-rely on "set -e" however:

    
    
      #!/usr/bin/env bash
      set -e
      fail() { false ; echo hello; }
      if ! fail; then :; fi
    

That outputs "hello" and exits with 0.

------
rdslw
If we're talking about GPG, please pay attention to
[https://www.passwordstore.org/](https://www.passwordstore.org/) which is
really cool, open source password manager built on GPG.

~~~
veeti
Is there anything like this that doesn't leak the folder structure in
plaintext? Manually obfuscating site names would be very tedious.

~~~
sorenjan
How about KeePass?

~~~
terrywang
I personally think it's a pretty good password manager (like all others,
database sync is a problem for users to solve). I had been using its Linux
port -> keepassx (also available for macOS - yes NOT Mac OS X any more...)

Features:
[http://keepass.info/features.html](http://keepass.info/features.html)

I switched to pass / qtpass (cross-platform Qt frond-end for pass) after
seeing it on hacker news (or somewhere else like Twitter) because it uses
GnuPG + git (simple and I am capable of both in CLI). Last but not least, pass
provides migration scripts from keepass/keepassx (and a lot more... - feel
like I had to migrate ;-)

------
RJIb8RBYxzAMX9u
Unless compatibility with gpg is a requirement, I think scrypt[0] is a much
simpler tool for file encryption. The utility is meant to showcase the KDF of
the same name. It's very simple and has virtually no parameters. So:

    
    
      $ xz -k elrond_minutes.txt
      $ scrypt enc elrond_minutes.txt.xz elrond_minutes.txt.xz.enc
      $ signify -S \
          -s vilya.key \
          -m elrond_minutes.txt.xz.enc \
          -x elrond_minutes.txt.xz.enc.sig
      $ rm elrond_minutes.txt{,.xz}
    

Signing the final output is probably extraneous; I think scrypt uses a HMAC.
This involves invoking multiple tools, but since each tool only does one thing
it's much easier to reason about, and I prefer this over using an omnibus tool
like gpg.

[0] [https://github.com/Tarsnap/scrypt](https://github.com/Tarsnap/scrypt)

~~~
agumonkey
My paranoid self wanted to replace rm with shred.

~~~
twr
You can just pipe xz instead, although you may want to shred the original
file:

    
    
      xz < file | scrypt enc - > file.xz.enc
    

And I agree: scrypt (the program) is much better for password encrypting
documents. It is only a few thousand lines of readable code; it uses modern
algorithm choices (scrypt, AES256-CTR, HMAC-SHA256), with no alternatives;
there isn't any configuration involved; and it's written by a respected
author.

------
parfe
>We suggest that you include five words of 5-10 letters in size, chosen at
random, with spaces, special characters, and/or numbers embedded into words.

>You need to be able to recall the passphrase that was used to encrypt the
file.

Why bother writing security guidelines which are impossible for a human to
follow?

edit: Try recalling any passphrases generated by the command below, and that's
before the random sprinkling of punctuation.

    
    
        grep -E "^[a-z]{5,10}$" /usr/share/dict/words | shuf -n5 | tr '\n' ' '

~~~
HappyTypist
Is it really impossible for a human to follow?

"Shiny C0rrect H0rse Battery Staple!"

~~~
LordKano
That's a good long term solution but when policies force you to change your
password every 45 days, it falls apart.

In my experience, overly restrictive password policies force users to choose
passwords that are less secure and easier to remember.

~~~
COil
Yes indeed. For example they add the current year and month and keep the same
"base password" which is unsafe.

~~~
e12e
"Password2017" is a typical "secure" password. Capital and small letters, and
number - longer than 8 characters. Passes most "checks" for passwords...

~~~
koolba
"Password2017!" is even better. It's got a _special_ character!

~~~
quickben
Funny how most people go for ! as the default special character :)

~~~
koolba
It adds to the excitement of logging into an application. Instead of "login",
you get to "login!".

------
oripel
Key stretching is critical for password-based encryption, and gpg's s2k
options are vulnerable to GPU acceleration. Command-line tools to encrypt with
bcrypt/scrypt are common and may be a better option.

------
kondbg
Is there a benefit in using symmetric encryption vs specifying yourself as a
recipient?

------
SeaDude
The HECC site here is one of the best support sites i've ever seen. Very
logically laid out KB, news, ask a question, etc.

thanks for the link

------
woliveirajr
There's the [2015] which should be included.

~~~
rdslw
No it shouldnt. It imposes (false) perception that anything not from today is
old/not fresh/known/bad knowledge. It is not true.

This hunt for dates in titles on HN is bad and it's awitch hunt these days.

Disclaimer: I'm not an author nor submitter.

~~~
teddyh
This is “Hacker _News_ ”.

~~~
grzm
The "News" is a bit of a misnomer. Any submission that "gratifies intellectual
curiosity" is on-topic, regardless of age.

------
discreditable
Why would they not use asymmetric encryption?

~~~
gcp
...and why encrypt stuff transferred with scp?

~~~
45h34jh53k4j
because encryption in transit != encryption at rest. Maybe you don't trust the
server you are scp'ing the data to, with encryption at rest you dont' need to.

~~~
gcp
That's not what the documentation is about, though:

====

Use GPG with the cipher AES256, without the --armour option, and with
compression to encrypt your files during inter-host transfers. GPG

Encryption helps protect your files during inter-host file transfers (for
example, when using the scp, bbftp, or ftp commands). We recommend GPG (Gnu
Privacy Guard), an Open Source OpenPGP-compatible encryption system.

===

scp shouldn't be in that list.

~~~
falcolas
If your goal is to transfer securely from person to person, 'scp' generally
means there's a common server you're accessing - not that you're 'scp'ing
directly to the other user's machine. Keeping it secure when "at rest" on the
remote server would ensure it's securely transferred between the two end
points.

