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

后端 未结 8 2043
感动是毒
感动是毒 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:22

    I found this solution on Mike Hike Hostetler's site that worked perfectly for me.

    # rsync -avz -e "ssh -p $portNumber" user@remoteip:/path/to/files/ /local/path/
    
    0 讨论(0)
  • 2020-12-12 09:26

    when you need to send files through a specific SSH port:

    rsync -azP -e "ssh -p PORT_NUMBER" source destination
    

    example

    rsync -azP -e "ssh -p 2121" /path/to/files/source user@remoteip:/path/to/files/destination
    
    0 讨论(0)
  • 2020-12-12 09:28

    use the "rsh option" . e.g.:

    rsync -avz --rsh='ssh -p3382' root@remote_server_name:/opt/backups
    

    refer to: http://www.linuxquestions.org/questions/linux-software-2/rsync-ssh-on-different-port-448112/

    0 讨论(0)
  • 2020-12-12 09:28

    I was not able to get rsync to connect via ssh on a different port, but I was able to redirect the ssh connection to the computer I wanted via iptables. This is not the solution I was looking for, but it solved my problem.

    0 讨论(0)
  • 2020-12-12 09:29

    A bit offtopic but might help someone. If you need to pass password and port I suggest using sshpass package. Command line command would look like this: sshpass -p "password" rsync -avzh -e 'ssh -p PORT312' root@192.xx.xxx.xxx:/dir_on_host/

    0 讨论(0)
  • 2020-12-12 09:32

    Your command line should look like this:

    rsync -rvz -e 'ssh -p 2222' --progress ./dir user@host:/path
    

    this works fine - I use it all the time without needing any new firewall rules - just note the SSH command itself is enclosed in quotes.

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