一般情况下,我们用rsync可以很容易的同步一个远程目录.

$ rsync -avzh --progress --delete \
    name@remote_host:source_dir target_dir

这样就把远程的一个目录同步回来了.

但是现在问题来了,当 port 为非标准的 22 端口时, 我们应该怎样加参数呢?比如有时候我们会 NAT 到 2222 端口.

答案很简单

$ rsync -avzh --progress --delete  -e "ssh -p 2222" \
    name@remote_host:source_dir target_dir

当然,rsync还有很多神奇的功能,各位请自行 man rsync.

reference : Rsync with a non-standard ssh port

Categories: Code

Yu

Ideals are like the stars: we never reach them, but like the mariners of the sea, we chart our course by them.

Leave a Reply

Your email address will not be published. Required fields are marked *