由于unison在远程同步文件夹要登陆远程服务器,因此要配置两机互相信任
本例假设本地机为:10.178.1.132(linux)
远程机:10.178.1.110(solaris)
1. 在两台机器上创建 RSA密钥
以下操作要在本地机和远程机上都执行一遍
(1)以 root 用户登录
(2)在 root 用户的 主目录内创建.ssh 目录并设置正确的权限
[root@gsgatzhapp1 ~]# mkdir ~/.ssh
[root@gsgatzhapp1 ~]# chmod 700 ~/.ssh
(3)使用 ssh-keygen 命令生成第 2 版本的 SSH 协议的 RSA 密钥
[root@gsgatzhapp1 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
17:e4:7c:79:8d:a0:00:3b:d9:f7:7a:56:f3:ac:54:4d [email=oracle@gsgatzhapp1]oracle@gsgatzhapp1[/email]
在提示保存私钥(key)和公钥(public key)的位置时,使用默认值。 如果需要私钥密码(passphrase),则输入一个私钥密码(如果使用私钥密码,使用 ssh 执行远程命令时需要输入私钥密码,因此,本案例中未使用私钥密码),因此,直接回车即可。
2. 添加密钥到授权密钥文件(authorized key file)中
(1)以 root 用户登录
(2)在本地机上执行
[root@gsgatzhapp1 ~] # cd ~/.ssh
[root@gsgatzhapp1.ssh]#ssh 10.178.1.132 cat /root/.ssh/id_rsa.pub >> authorized_keys
[oracle@gsgatzhapp1.ssh]#ssh 10.178.1.110 cat /root/.ssh/id_rsa.pub >> authorized_keys
[oracle@gsgatzhapp1.ssh]#scp authorized_keys 10.178.1.110:/root/.ssh/
[oracle@gsgatzhapp1 .ssh]# chmod 600 /root/.ssh/authorized_keys
(3)在远程机10.178.1.110 上:
bash-2.05# chmod 600 /root/.ssh/authorized_keys
(4)测试
完成后,在 gsgatzhapp1 上执行:
[root@gsgatzhapp1 ~]# ssh 10.178.1.132 date
[root@gsgatzhapp1 ~]#ssh 10.178.1.110 date
如果不需要输入密码就出现系统日期,说明 SSH 配置成功。作者: mikema 时间: 2007-12-10 10:26 标题: Unison使用文档(下) 四:unison的使用
Unison可以在一台主机上使用,同步两个文件夹,也可以在网络上是用。
1:本地使用
使用方法:
#unison 111 222 #同步本地的111和222文件夹
Contacting server...
Looking for changes
Warning: No archive files were found for these roots. This can happen either
because this is the first time you have synchronized these roots,
or because you have upgraded Unison to a new version with a different
archive format.
Update detection may take a while on this run if the replicas are
large.
Unison will assume that the 'last synchronized state' of both replicas
was completely empty. This means that any files that are different
will be reported as conflicts, and any files that exist only on one
replica will be judged as new and propagated to the other replica.
If the two replicas are identical, then no changes will be reported.
Press return to continue.[<spc>] Reconciling changes
111 222
<---- file aaaaaaaaaaaaa [f] ?
Commands:
<ret> or f or <spc> follow unison's recommendation (if any)
I ignore this path permanently
E permanently ignore files with this extension
N permanently ignore paths ending with this name
m merge the versions
d show differences
x show details
l list all suggested changes
p or b go back to previous item
g proceed immediately to propagating changes
q exit unison without propagating any changes
/ skip
> or . propagate from left to right
< or , propagate from right to left
<---- file aaaaaaaaaaaaa [f] f
Proceed with propagating updates? [] y
Propagating updates
如何在和远程服务器同步大量数据,上传一部分数据后,超时:
9% 559:15 ETARead from remote host bluehost: Connection reset by peer
Fatal error: Lost connection with the server
实际操作中,最好的方法是,第一次先把要上传的文件打成包,用 ftp 上传,然后展开到服务器中,之后执行一次 unison 同步即可。