Search code examples
vimscpneovim

Neovim scp doesn't prompt for password


In Vim, this prompts me for a password allowing me to edit a remote file:

:e scp://username@host//path

Yet, using the same command with NeoVim doesn't prompt for a password because the underlying command :! scp user@host:path LOCAL-TEMPFILE does not work interactively in NeoVim: https://github.com/neovim/neovim/wiki/FAQ#-and-system-do-weird-things-with-interactive-processes

What is the best practice to edit a remote file with NeoVim that has password authentication over ssh?


Solution

  • I would guess that the netrw plugin that provides this functionality isn't installed / active for Neovim. Check whether the :Nread command is available. Compare the :scriptnames output from Vim and Neovim. Read the plugin's documentation :help pi_netrw for how to install and enable it.

    Update: So, it turns out that there's an Neovim issue with interactive commands started from :!, and this is what netrw is doing; the plugin does not capture the password challenge. It's basically executing :! scp user@host:path LOCAL-TEMPFILE

    If you can avoid the issue (use key-based SSH authentication for the hosts), you could continue to use Neovim with netrw. If this is really important to you, more elaborate workarounds are possible. (For example, I use a wrapper around ssh that parses ~/.ssh/config for custom Password Hunter2 entries (these passwords are well known in the org and only used for testing VMs, so no security issue here), and then uses sshpass to automatically log in.)

    Else, you have to switch to classic Vim for netrw operations, or use another way of accessing these remote files (e.g. SSHFS).