(Update 04/08/2007: apparently I’m number one for most searches about editing with Vim over SSH, so I’ll note for other searchers that this method isn’t perfect, but it gets the job done. The downside to this method is that it keeps asking for a password for every file operation.
Also note that the reason it’s problematic is you can’t send a password to scp, and netrw doesn’t support SSH.)
I have a lot of Nautilus folders set up to use SSH on some of our file servers, here at work. It’s very handy to be able to browse remote files, but unfortunately Vim/GVim (my editor of choice) doesn’t understand files starting with ssh:// With the netrw plugin, one can open files via scp://, however.
The solution involves severall things.
- netrw plugin for vim. I believe this is bundled with 7.0
- ssh-askpass/ssh-askpass2. I used apt-get to install ssh-askpass… my gvim kept looking for ssh-askpass2, however. So I did the following command: sudo ln -s /usr/bin/ssh-askpass /usr/local/bin/ssh-askpass2.
- Follow these instructions to create a menu extension that will convert ssh to scp on file opens
It’s not an optimal solution because it doesn’t use the gnome keyring manager… it will pop open a box prompting for a password. Still, it’s pretty useful if you really just want to edit files in Vim.

2 responses so far ↓
1 Grant McLean // May 14, 2007 at 5:58 pm
I’m pleased you liked my Nautilus ‘plugin’ for invoking GVim over SSH. Did you take a look at bcvi:
http://www.perlmonks.org/index.pl?node_id=611462
I’ve found it to be much more useful than the Nautilus plugin because I tend to spend more time ‘browsing’ remote servers from a shell rather than from Nautilus.
I’m not sure why you’re keying your password every time you use scp. Can you not add your key to .ssh/authorized_keys on the remote server? Then you simply enter your password once to add your key to the SSH agent on your workstation and SSH/SCP will be password-less from then on.
You might also want to check out my SSHMenu applet which can be used to add all your SSH connections as a menu on your GNOME panel. You can also use this menu to lock/unlock your key in the ssh agent:
http://www.mclean.net.nz/ruby/sshmenu/
Cheers
Grant
2 Chip Hogg // Feb 6, 2008 at 7:12 pm
I had a hard time getting this thing to work, and found the whole public/private key thing confusing. However, I found this link written by Daniel Robbins of Gentoo fame:
http://www.ibm.com/developerworks/linux/library/l-keyc.html
He explains in patient detail how to set up automatic RSA/DSA authentication so that you don’t have to enter your passphrase every time. I have read this article and also the next one (link at the bottom), part 2, which explains how to use ssh-agent to remember your passwords. So far, this works beautifully if I launch gvim from a shell, but not if I launch it with a keybord shortcut from my WM, since ssh-agent runs in the shell. I think there might be a way to use gentoo’s keychain to get around this, but I’m not sure.
http://www.gentoo.org/proj/en/keychain/
Anyway, the first link should probably be people’s best bet for getting secure passwordless authentication working with gvim over SSH.
Leave a Comment