Edit a file through an on-the-fly encryption stream in Unix

5

Okay this is a weird sort of question. I might get down-voted for being stupid here.

I'd like to be able to edit an encrypted file, but without having to manually decrypt it to a location on the disk.

I see the workflow going something like this:

  • I type a unix command, naming the encrypted file to edit
  • I enter the password to decrypt the file stream
  • A graphical editor opens containing the decrypted version of the file
  • I can edit the file, and whenever I save it gets encrypted on the fly back into the encrypted file
  • When I close the editor, only the encrypted file remains

I kinda thought it should be possible to get an editor to talk to an on-the-fly encryption stream but think it was talking to a normal file. Something like:

$ sublime-text | open-gpg-stream my-encrypted-file.gpg
password: 

Is this possible? Or is my understanding just way off? If this isn't possible, could you please explain why it's not possible?

Robin Winslow

Posted 2013-06-14T23:07:58.347

Reputation: 238

Answers

3

It’s not a weird question, but you might do better simply looking for an editor that already, natively, does what you want.  For example, vi and vim do.  Just don’t post a question to Super User asking, “Where can I buy …?”

Failing that, can you wrap your favorite graphical (but encryption-unaware) editor in a script that handles the encryption part?  I understand that you don’t want to write the file to disk in the clear –– but can you decrypt the file and write it to a tmpfs file system (RAM disk) or an encrypted file system?

Scott

Posted 2013-06-14T23:07:58.347

Reputation: 17 653

@RobinWinslow try gvim – graywolf – 2015-11-20T16:37:28.080

Ah! vim is the perfect solution. I just do vim -x myfile.txt and it works exactly as I want. I have version 7.3 according to this article it should be using the fairly decent blowfish cypher. I'd still like to know if there is an easy way to achieve this for a graphical editor, but vim is a perfectly good solution. Thanks.

– Robin Winslow – 2013-06-16T17:35:31.930