rsync和ssh使用方法

rsync同步或ssh ip时需要输入服务器密码,可以通过如下操作实现无密码安全操作。

1.产生公匙文件,注意不要输入passphrase

[wm@adx .ssh]$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/wm/.ssh/id_dsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/wm/.ssh/id_dsa.
Your public key has been saved in /home/wm/.ssh/id_dsa.pub.
The key fingerprint is:
9b:fc:6f:fc:7f:4b:22:8f:9f:db:91:ef:3f:39:b0:6f wm@adx
[wm@adx .ssh]$ ls -al
total 28
drwx------ 2 wm wm 4096 Oct 22 10:15 .
drwxrwx--- 9 wm wm 4096 Oct 22 10:01 ..
-rw------- 1 wm wm  668 Oct 22 10:15 id_dsa
-rw-r--r-- 1 wm wm  596 Oct 22 10:15 id_dsa.pub
-rw------- 1 wm wm 1671 Sep 28 19:01 id_rsa
-rw-r--r-- 1 wm wm  388 Sep 28 19:01 id_rsa.pub
-rw-r--r-- 1 wm wm 1211 Oct 21 18:09 known_hosts

 -t type
             指定要创建的密钥类型。可以使用:"rsa1"(SSH-1) "rsa"(SSH-2) "dsa"(SSH-2)。

提示创建.ssh/id_rsa、id_rsa.pub的文件,其中第一个为密钥,第二个为公钥。

2.将公钥文件传送到需要登陆的服务器

[root@adx ~/.ssh]# scp id_rsa.pub root@192.168.1.25:/data/


3.登陆192.168.1.25服务器

[root@adx ~/.ssh]# ssh 192.168.1.25
Last login: Wed Oct 22 08:33:44 2014 from 192.168.1.151

4.将刚才的公钥文件内容添加到用户的.ssh目录下的authorized_keys文件中

[root@tadx data]# cat id_rsa.pub >> /root/.ssh/authorized_keys

5.退出后再次登录,不需要密码。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值