Linux两个小实验2018-05-14

1、不互信情况下 ,000机器scp一个文件到001机器,无需密码操作

000

[root@hadoop000 ~]# rm -rf ~/.ssh

[root@hadoop000 ~]# ssh-keygen

[root@hadoop000 ~]# cd .ssh

[root@hadoop000 .ssh]# cat id_rsa.pub >> authorized_keys

001

[root@hadoop001 ~]# rm -rf ~/.ssh

[root@hadoop001 ~]# ssh-keygen

[root@hadoop001 ~]# cd .ssh

[root@hadoop001 .ssh]# cat id_rsa.pub >> authorized_keys

000

[root@hadoop000 .ssh]# scp id_rsa.pub 192.168.137.128:/root/.ssh/id_rsa.pub.hadoop000

001

[root@hadoop001 .ssh]# cat id_rsa.pub.hadoop000 >>authorized_keys

[root@hadoop000 ~]# scp 111.log 192.168.137.128:/tmp111.log 100% 0 0.0KB/s 00:00

2、ssh两台机器配置互相信任关系

1、清空两台机器的.ssh,并生成公钥

[root@hadoop000 ~]# rm -rf ~/.ssh

[root@hadoop000 ~]# ssh-keygen

[root@hadoop001 ~]# rm -rf ~/.ssh

[root@hadoop001 ~]# ssh-keygen

2、选择000作为先完善的机器

[root@hadoop000 .ssh]# cat id_rsa.pub >> authorized_keys

3、001将id_rsa.pub发送给第一台

[root@hadoop001 .ssh]# scp id_rsa.pub 192.168.137.130:/root/.ssh/id_rsa.pub.hadoop001

4、000中将001的id_rsa.pub追加到authorized_keys

[root@hadoop000 .ssh]# cat id_rsa.pub.hadoop001 >> authorized_keys

5、然后将authorized_keys分发

[root@hadoop000 .ssh]# scp authorized_keys 192.168.137.128:/root/.ssh/

每台机器的第一次要确认

Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.137.130' (RSA) to the list of known hosts

你可能感兴趣的:(Linux两个小实验2018-05-14)