-x option encryption

31 views
Skip to first unread message

Stevew

unread,
Jan 12, 2020, 10:24:05 AM1/12/20
to vim_use
is the  a way to automatically put the password in the startup command. 
E.G.

vi -x mypassword mynicefile.txt

This of course does not work. But is the a way to do something like this?

thanks.

Salman Halim

unread,
Jan 12, 2020, 10:38:51 AM1/12/20
to Vim Users
This isn't what you asked, of course, but it seems problematic to me to have the password become part of your command-line history in plain text. Defeats one of the protections provided by the encryption.

--

Salman

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/5a69ee06-aafe-4a4d-9221-6e325bf184ec%40googlegroups.com.

Grant Taylor

unread,
Jan 12, 2020, 11:54:17 AM1/12/20
to vim...@googlegroups.com
On 1/12/20 8:24 AM, Stevew wrote:
> is the a way to automatically put the password in the startup command.

If your goal is to open vim and work with encrypted files without the
hassle of decrypting them, there is an option.

I've installed a plugin that will automatically decrypt GPG encrypted
files on open and encrypt on write / close. It interfaces with the GPG
agent to access the keys as necessary.

Depending on how the GPG agent is configured, if the key is in memory,
you will not be prompted for any pass phrase.

> But is the a way to do something like this?

I don't know if what I described above will do what you want or not.

> thanks.

:-)



--
Grant. . . .
unix || die

Stevew

unread,
Jan 12, 2020, 3:48:01 PM1/12/20
to vim_use
thanks for your responses.

I'm really just looking for a command line option as I mentioned. I didn't seem one and it appears there is none.

As far as being in memory or history.  I'm not that concerned. The files are not exactly the colonel's recipe.

Thanks.

Andy Wokula

unread,
Jan 13, 2020, 12:23:26 PM1/13/20
to vim...@googlegroups.com
You can set a key with :set key=mycoolkey

This works here (doubles quotes = on Windows):



vim --cmd "set key=mycoolkey" mynicefile.txt



(needless to say this is not recommended ...)



--

Andy

Grant Taylor

unread,
Jan 13, 2020, 1:16:20 PM1/13/20
to vim...@googlegroups.com
On 1/13/20 10:22 AM, 'Andy Wokula' via vim_use wrote:
> You can set a key with :set key=mycoolkey

Interesting.

> This works here (doubles quotes = on Windows):
>
> vim --cmd "set key=mycoolkey" mynicefile.txt

I wonder if it would be possible to play with other methods to populate
the "mycoolkey" text. Admittedly, they aren't as Windows friendly.

Environment variables are the first thing that comes to mind.

After that is file redirection, possibly from a sub-command.

Finally, a full sub-command that extracts the password out of something,
possibly GPG protected file. }:-)

> (needless to say this is not recommended ...)

I know that the typical gotchas are the output of ps (et al.) and
methods to access other processes environment variables. What other
concerns are there that my uncaffeinated brain is missing?

Tim Chase

unread,
Jan 13, 2020, 1:45:42 PM1/13/20
to 'Grant Taylor' via vim_use
On 2020-01-13 11:16, 'Grant Taylor' via vim_use wrote:
> On 1/13/20 10:22 AM, 'Andy Wokula' via vim_use wrote:
> > You can set a key with :set key=mycoolkey
>
> Interesting.
>
> > This works here (doubles quotes = on Windows):
> >
> > vim --cmd "set key=mycoolkey" mynicefile.txt
>
> I wonder if it would be possible to play with other methods to
> populate the "mycoolkey" text. Admittedly, they aren't as Windows
> friendly.
>
> Environment variables are the first thing that comes to mind.

Did a quick test:

$ vim delme.txt
[add some text]
:set key=secret
:wq
$ KEY="$(echo secret)" vim +'let &key=$KEY | e delme.txt

which lets you use any method you want to obtain the secret key
(using the super-secure "echo" method of password storage here)

Alternatively, you could obtain the key without the environment
variable, though note that the trailing newline becomes part of the
password:

$ echo secret > password.txt
$ vim delme.txt
[add some text]
:let &key=system('cat password.txt")
:wq
$ vim +'let &key=system("cat password.txt") | e delme.txt'

where you can use whatever program you want in place of

"cat password.txt"

to obtain your password.

-tim






Stevew

unread,
Jan 14, 2020, 11:36:40 AM1/14/20
to vim_use
Hey andy that works .
Thanks. 
Reply all
Reply to author
Forward
0 new messages