- 论坛徽章:
- 0
|
相信来看本贴都是高手,最近在使用rsync作同步时却遇到了一个不小的麻烦.内网从外网的服务器上同步数据回来做备份,应该说使用rsync是很方便的,由于考虑文件的安全性肯定要采用ssh方式了,问题就出在这里,因为同样出于安全ssh端口更改为不是22的非常用端口,rsync的使用参数中找不到如何来指定ssh的端口.在rsync的官方网站:rsync.samba.org的如何绕过防火墙的回答中好像找到了方法:
The first thing we need is an ssh configuration that will allow us toconnect to the forwarded port as if we were connecting to the targetsystem, and we need ssh to know what we're doing so that it doesn'tcomplain about the host keys being wrong. We can do this by adding thissection to your ~/.ssh/config file (substitute "target" and "target_user"as appropriate, but leave "localhost" unchanged):
Host target
HostName localhost
Port 2222
HostKeyAlias target
User target_user
Next, we need to enable the port forwarding:
ssh -fN -l middle_user -L 2222:target:22 middle What this does is cause a connection to port 2222 on the local system toget tunneled to the middle system and then turn into a connection to thetarget system's port 22. The -N option tells ssh not to start a shell onthe remote system, which works with modern ssh versions (you can run asleep command if -N doesn't work). The -f option tells ssh to put thecommand in the background after any password/passphrase prompts.
With this done, you could run a normal-looking rsync command to "target"that would use a connection to port 2222 on localhost automatically:
rsync -av target:/src/ /dest/
但百试不灵,不知各位大侠还有什么其他高招?
|
|