Skip to content

[Bug] rsync does not support custom remote ssh port #30

@alexrah

Description

@alexrah

Describe the bug

when setting a host with a port in deployment.lua

return {
  ["myremote"] = {
    host = "hostname:22250",
    username = "foo",
    mappings = {
      {
        ["local"] = "/",
        ["remote"] = "/",
      },
    },
  },
}

the host works as expected when operations are run through scp but they don't work using rsync.
The commands (based on rsync) lacking support are:

  • TransferDownload or TransferUpload when path is a dir
  • TransferDirDiff

How to reproduce

  1. set host with syntax hostname:port
  2. run either TransferDownload, TransferUpload on a dir or TransferDirDiff

Error shown:

Host key verification failed.
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255)

Expected behavior

  • diff the directory with the remote one and display the changed files in the quickfix
  • sync the files

System

  • OS: MacOS 13.5.2
  • NVIM v0.11.3
  • transfer.nvim commit: af75ad5

Solution

  • I'm working on a pull request with a modified remote_rsync_path() to extract port numbers from host strings
  • rsync doesn't support hostname:portnumber syntax, but it requires to define the port using extended options, i.e. -e "ssh -p {portnumer}"
  • to avoid command execution issues with extended options, need to pass a string instead of a list to vim.fn.jobstrart -> vim.fn.jobstart(table.concat(command, " "),{...})

Especially about the last point, do you think that could have some side effects?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions