iVim icon indicating copy to clipboard operation
iVim copied to clipboard

scp seems to execute curl

Open anjiro opened this issue 4 years ago • 4 comments

When I run !scp user@host file . I see the curl progress indicator followed by an error message. Depending on whether the remote host has vim's SSH key, either curl (67) authentication failure or curl (79) failed to recv file.

This problem also manifests when trying to edit a remote file (:e scp://...); there are no errors, but the file is always empty and changes are never written to the remote.

anjiro avatar Apr 24 '21 12:04 anjiro

Right now, command scp is a wrapper around curl.

As to the remote editing problem, it may have something to do with the authentication. You can refer to https://github.com/terrychou/iVim/wiki/External-Command:-ssh for some details.

terrychou avatar Apr 26 '21 12:04 terrychou

Yes, I followed those instructions and authentication seems to work; for example, netrw can list directory contents and I can run :!ssh user@host without being asked for a password. But the problems above happen even so.

anjiro avatar Apr 27 '21 10:04 anjiro

I've figured out the issue. Regular scp defaults to paths relative to the home directory; that is, scp user@host:file.txt will get file.txt from user's home directory. But curl assumes paths relative to root, so curl -u user: scp://host/file.txt will try to get file.txt from /. Instead, you have to use curl -u user: scp://host/~/file.txt.

When using netrw to browse a directory via :e scp://user@host/, it correctly lists buser's home directory, but when selecting a file to edit, the call to curl doesn't include the ~ (probably because netrw is expecting stock scp rather than curl), so the result is an empty file. The same issue likely is happening on the write-side.

anjiro avatar Apr 29 '21 09:04 anjiro

Yes, you are right. It behaves like this is right because of the curl wrapping implementation.

terrychou avatar May 02 '21 02:05 terrychou