6 ms·
Ask HN: CLI Tool for File Encryption?
I recently came across sigtool[1] which on the surface looks like a slightly more well defined tool/format for encryption than age[2].
And they both attempt to be simpler, more modern than gnupg[3] and easier to use than eg: openssl[4].
Which tool do you use/recommend for encrypting files, and why?
My primary use case is for backups - but interested in other use-cases as well.
[1] https://github.com/opencoff/sigtool https://github.com/opencoff/sigtool
[2] https://github.com/FiloSottile/age https://github.com/FiloSottile/age
[3] https://gnupg.org/ https://gnupg.org/
[4] https://wiki.openssl.org/index.php/Enc https://wiki.openssl.org/index.php/Enc
- barnabee 5y agoI’ve had good experiences with age [1]: it’s relatively easy to use and has sane defaults. [1] https://github.com/FiloSottile/age https://github.com/FiloSottile/age
- trevormcneal 5y agoGPG, I just plug this into my server and is done https://github.com/opsxcq/ansible-role-host-backup https://github.com/opsxcq/ansible-role-host-backup
- bertman 5y agoI'm using restic -r sftp:<backupserver>:<repo> --password-command="pass mybackup" backup <folders_to_backup> https://restic.readthedocs.io/en/latest/ https://restic.readthedocs.io/en/latest/
- krnlpnc 5y agoHave you looked into rclone?
- exyi 5y agoWhen I want symmetric-key encryption which can even be opened by average Windows user, I just use `7z a output-file.7z input-file.txt -p"password"`
- FiloSottile 5y agoHello! age (https://age-encryption.org https://age-encryption.org) author here. Different tools can definitely be better for different use cases (for example I am a fan of restic [0] for backups, although age is designed to compose well with tar, if that's your thing), but do you mind me asking what made that tool feel more well defined than age? age has a stable spec [1] and an alternative implementation in Rust [2] based on the spec with extensive interop tests. If that’s just not visible, I’d be interested in how to fix that appearance, too! [0]: https://words.filippo.io/restic-cryptography/ https://words.filippo.io/restic-cryptography/ [1]: https://age-encryption.org/v1 https://age-encryption.org/v1 [2]: https://github.com/str4d/rage https://github.com/str4d/rage
- e12e 5y agoI may have been too quick to judge - I first thought sigtool was a superset of openbsd signify - not a work-a-like. And it appeared sigtool's approach with probuf was somewhat sturdier than a custom spec/format (although the age spec does look quite nice and straightforward). Additionally, I came across some comments on age's custom primitives - but I suppose that's also similar for the two. Ed: thank you for your work on age!
- GekkePrutser 5y agoAre you planning to support hardware encryption tokens also like GPG does with OpenPGP cards? For me this is an absolute must-have in order to even consider age as an alternative for GPG/PGP. GPG's codebase is not great indeed, but in this case it's not super important as the key generation happens inside the actual token anyway.
- FiloSottile 5y agoYes! That’s what the plugin system is designed for. https://github.com/str4d/age-plugin-yubikey https://github.com/str4d/age-plugin-yubikey is fairly mature and I use it every day. Currently it's only compatible with https://github.com/str4d/rage https://github.com/str4d/rage, because age only supports plugins in a branch, but I'm hoping to land support this week!
- zokier 5y agoage is the one thing that has any degree of mindshare. Technically it is certainly good enough for ensuring confidentiality. There are gazillion somewhat similar also-ran encryption tools, but their benefits are not there compared to their relative obscurity
- neatze 5y agoNot sure what is implied specifically by "modern" outside of library's age, but it is really hard to beat setup of Yubikey's with OpenPGP and bash scripts using luks or tar depending on encrypted files use case.
- FiloSottile 5y agohttps://github.com/str4d/age-plugin-yubikey https://github.com/str4d/age-plugin-yubikey is very much trying to beat GnuPG for ease of use and performance in that setup :) Currently it's only compatible with https://github.com/str4d/rage https://github.com/str4d/rage, because age only supports plugins in a branch, but I'm hoping to land support this week!
- Jamie9912 5y ago7zip
- chasil 5y agoI wrote an article about OpenSSL some time ago, and it's Google's top hit on "openssl flat file encryption." I've heard great criticism of directly using the RSA functions, but they do work for the exchange of a very small amount of data. Newer versions of OpenSSL offer chacha20-poly1305 in the "enc" symmetric ciphers. https://www.linuxjournal.com/content/flat-file-encryption-openssl-and-gpg https://www.linuxjournal.com/content/flat-file-encryption-op... I use p7zip for encrypted backups, even though the AES implementation is far from best practice. https://piunikaweb.com/2019/02/01/insecure-aes-crypto-implementation-in-7zip-found-by-user/ https://piunikaweb.com/2019/02/01/insecure-aes-crypto-implem...
- FiloSottile 5y agoHeh, a problem we honestly have with age is that the whole article (including SSH key support!) would be a one-liner with age, so it just doesn't get written and it doesn't get SEO :) It's a good problem to have, but I find it funny.
- chasil 5y agoI've been thinking about what my job would be like on the morning of a ransomware outbreak. I think that I'd be asked a set of questions: - Do you have offline/airgapped backup media? - Do you have signed sha256 signatures that can verify the backups? - Do you have secure systems and spare media to make copies of these backups? Does your tool do all of this? Also, do you use AEAD ciphers without separate MACs? We have a lot of HP iLO, and when those get infected the server needs to be junked (I don't know any way to remove iLO malware). I'd actually prefer something where the Intel ME is completely disabled, just to be safe (time to dig up a Core 2 Duo).
- ale42 5y agoNot sure if you are looking to single-file backups or an actual backup solution that includes good encryption. I have very good experience with restic (https://restic.net/ https://restic.net/), which encrypts all backups and does deduplication, using it on production servers with millions of files, as well as for home use (rather 100k files order of magnitude). It would be a bit too cumbersome for single-file use, though.
- chrisdew 5y agoI use Turnstile: https://github.com/fadedbee/turnstile https://github.com/fadedbee/turnstile
- aborsy 5y agoYou have to be careful with unknown scripts/apps on GitHub. They may not be reviewed, may disappear or not maintained next year, file formats might be specific or not supported by other tools. The benefits are also dubious over well established tools like OpenSSL (if you just want to encrypt a file from command line). Use widely-used well-known tools. File encryption is a commodity!
- deleted 5y ago[deleted]
- byteshock 5y agoIf I need to encrypt a file for quick sharing, I’ll use gpg. Encrypt: gpg -c file.zip Decrypt: gpg file.zip.gpg However, for my personal files on my computer, I use a Veracrypt container with a strong password and custom pin.
- e12e 5y agoThank you everyone for your input. My use-case for simple cli encryption is mostly for single files - not part of a full backup solution (for that I'm leaning towards zfs send with encrypted file systems). This is more of a one-off tar czf - $HOME | encrypt > /mnt/usbstick.tgz.enc type thing - or for sharing encrypted files. But I agree 7zip is a decent option for the latter.
- user3939382 5y agoI use gnupg for this because it’s widely used/battle tested https://blogs.sap.com/2022/04/23/how-to-encrypt-and-decrypt-files-using-gpg-for-files/ https://blogs.sap.com/2022/04/23/how-to-encrypt-and-decrypt-... For anything critical, I try to avoid tools that are neat/cool but developed by small teams or individuals where the maintenance could suddenly disappear, which is common.
- chockablocker 5y agogocryptfs uses file-based encryption that is implemented as a mountable FUSE filesystem. Each file in gocryptfs is stored one corresponding encrypted file on the hard disk. Filenames are encrypted as well. https://nuetzlich.net/gocryptfs/quickstart/ https://nuetzlich.net/gocryptfs/quickstart/
- aborsy 5y agoIf you want backups, Restic or Borg. I use Restic. If you want file encryption, gpg -c (AES 256) or gpg -e (cv25519, optionally signed with ed25519). Frankly, there are tons of choices for file encryption. If you want file system encryption, ZFS native encryption. There is fscrypt for other Linux file systems, but it doesn’t support authenticated encryption AFAIK. If you want disk encryption, LUKS. Better yet, use file system encryption with a better mode and authenticated encryption. If you want per file encryption of a directory, consider rclone which uses secret box from NACL (or gocryptfs which uses OpenSSL). There are many other options such as cryptomator (written in Java), but I can’t confirm them!
- nicolaslem 5y ago> If you want backups, Restic or Borg. This. Backup is too important to make the mistake of rolling your own.
- GekkePrutser 5y agoFor me GPG is still the #1. The main reason is the ability to use physical smartcards for encryption (or the openPGP applet on a yubikey). Until 'age' can match that, it is no alternative for me.
- deleted 5y ago[deleted]
- zvr 5y agoMany interesting comments in this thread -- thanks, everyone! But a related question: how to handle long-term usage? I mean, I had some scripts which were essentially using "openssl enc -bf -salt" and this has worked fine for more than a decade. But at some point (I think when OpenSSL went from 1.1.0 to 1.1.1), OpenSSL started generating a warning about "deprecated key derivation" and suggesting "using -iter or -pbkdf2". Now, I can obviously update the scripts, but then the need to start storing metadata arises: this file was encrypted with this method, but this one with the other method. I am confident that such issues arise with any long-running process. How to cope with the issue?
- _paulc 5y agoIf you want a simple lightweight symmetric crypt CLI utility try ccrypt: http://ccrypt.sourceforge.net/ http://ccrypt.sourceforge.net/
- lioeters 5y ago> A simple shell utility for encrypting and decrypting files using OpenSSL https://github.com/nodesocket/cryptr https://github.com/nodesocket/cryptr