一、rsync协议收集数据

1、处理ssh免登

A、B两台服务器,要实现服务器B不用密码直接登录到A服务器上,需要如下操作

1.1、在B服务器执行命名生成密钥

ssh-keygen -t rsa

同时会在B服务器创建成~/.ssh文件夹,生成的公钥文件和私钥文件就保存在这里。

[xxxx@t0-xxxxxxx-txxx03 .ssh]# pwd
/root/.ssh
[xxxx@t0-xxxx-tdas03 .ssh]# ll
total 8
-rw------- 1 root root 887 Aug  1 16:57 id_rsa
-rw-r--r-- 1 root root 237 Aug  1 16:57 id_rsa.pub

1.2、查看A服务器的.ssh目录

查看A服务器准备免登录账号对应的“~/”目录下,是否有“.ssh”文件夹,如果没用使用“ssh-keygen”命令创建。

1.3、将B的公钥同步到A服务器

ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]

通过该命令B服务器的公钥会追到A服务器的ftpuser账号的 .ssh/authorized_keys文件里。

[ftpxxxx@t0-xxxxxx-tdxx01 .ssh]$ cat authorized_keys 
ssh-rsa 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxx@t0-xxxx-tdxx02
ssh-rsa xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx== xxxx@t0-xxxxx-tdas03

注:直接将对应的公钥证书文件id_rsa.pub的内容拷贝到.ssh/authorized_keys也可以达到相同的效果。

1.4、B服务器修可以免密码直接登录A服务器了

[xxx@t0-xxxxx-tdas03 .ssh]# ssh [email protected]
Warning: Permanently added '10.xxx.xxx.4' (ECDSA) to the list of known hosts.
Last login: Mon Aug  1 16:56:58 2016 from 10.xxx.xxx.5
[ftpxxxx@t0-xxxxxxxx-tdxx01 ~]$ ls
anbc  ping.sh  shterm_log  test

2、实现文件同步

参考资料 http://www.jb51.net/article/60192.htm

使用指定证书登录:

rsync -avR -e "ssh -i /home/anbc/.ssh/id_rsa" /home/anbc/anbc_test  [email protected]:/home/ftpuser/test

results matching ""

    No results matching ""