Is it possible to specify a different ssh port when using rsync?

后端 未结 8 2044
感动是毒
感动是毒 2020-12-12 08:44

I have been attempting the following command:

rsync -rvz --progress --remove-sent-files ./dir user@host:2222/path

SSH is running on port

相关标签:
8条回答
  • 2020-12-12 09:35

    Another option, in the host you run rsync from, set the port in the ssh config file, ie:

    cat ~/.ssh/config
    Host host
        Port 2222
    

    Then rsync over ssh will talk to port 2222:

    rsync -rvz --progress --remove-sent-files ./dir user@host:/path
    
    0 讨论(0)
  • 2020-12-12 09:38

    The correct syntax is to tell Rsync to use a custom SSH command (adding -p 2222), which creates a secure tunnel to remote side using SSH, then connects via localhost:873

    rsync -rvz --progress --remove-sent-files -e "ssh -p 2222" ./dir user@host/path

    Rsync runs as a daemon on TCP port 873, which is not secure.

    From Rsync man:

    Push: rsync [OPTION...] SRC... [USER@]HOST:DEST

    Which misleads people to try this:

    rsync -rvz --progress --remove-sent-files ./dir user@host:2222/path

    However, that is instructing it to connect to Rsync daemon on port 2222, which is not there.

    0 讨论(0)
提交回复
热议问题