Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

So I created a gpg encrypted file with password:

gpg -c passwords.txt.gpg

how can I open it with vi, edit it, then close it? (So that no passwords.txt file will be created, the decrypted passwords.txt is only in the memory! - better: after closing the passwords.txt.gpg file, the memory should be cleaned, so it shouldn't contain unencrypted passwords).

share|improve this question
    
You may be looking for a password manager such as keepass. It has command line functionality, and a GUI. –  jordanm Aug 28 '12 at 15:04

2 Answers 2

up vote 5 down vote accepted

The gnupg plugin for Vim does this:

This script implements transparent editing of gpg encrypted files. The filename must have a ".gpg", ".pgp" or ".asc" suffix. When opening such a file the content is decrypted, when opening a new file the script will ask for the recipients of the encrypted file. The file content will be encrypted to all recipients before it is written. The script turns off viminfo and swapfile to increase security.

share|improve this answer
    
works, thank you! –  gasko peter Aug 31 '12 at 17:50

If you truly mean a gpg file, then the gnupg plugin as mentioned is your best option.

If you mean "how can I open, edit, and save an encrypted file with vim" then you might also explore the -x option. It will allow you to enter a password and then save the file in an encrypted form, and does the right thing in terms of encrypting the .swp file as well.

See: http://vimdoc.sourceforge.net/htmldoc/editing.html#encryption

Be advised:

  1. the cm=blowfish option is vital, otherwise you're saving with very weak crypto
  2. I don't know if vim scrubs the memory before exit

Also, I don't know if keepass (mentioned above) as a command-line counterpart for Linux, but PasswordSafe (available for Windows and Linux) does: http://nsd.dyndns.org/pwsafe/ It allows you to edit entries in the shell, though if you want more freeform notes, full-screen editing, etc. you'd want something vi-friendly.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.