码迷,mamicode.com
首页 > 系统相关 > 详细

Linux 双机互信

时间:2016-02-29 14:46:38      阅读:294      评论:0      收藏:0      [点我收藏+]

标签:linux 双机互信 ssh 有效性

环境:

192.168.75.128 redhat6.5 x86_64

192.168.75.130 redhat6.5 x86_64


一、在192.168.75.130上操作

1、在~/.ssh目录下产生公钥与私钥对.

# ssh-keygen  

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:

e4:bb:24:9c:f9:01:a8:80:4d:db:66:5b:47:48:c5:ca root@slave0.localdomain.com

The key‘s randomart image is:

+--[ RSA 2048]----+

|      .o.        |

|     . ..        |

|  .  ...o        |

|.o o .E+         |

|o o = o S        |

| . + + = .       |

|  . . = +        |

|       + o       |

|        o        |

+-----------------+


2、ssh-copy-id 将公钥id_rsa.pub的内容追加到远程机器的 ~/ .ssh/authorized_key.文件中

# ssh-copy-id  -i ~/.ssh/id_rsa.pub 192.168.75.128  

root@192.168.75.128‘s password: 

Now try logging into the machine, with "ssh ‘192.168.75.128‘", and check in:


  .ssh/authorized_keys


to make sure we haven‘t added extra keys that you weren‘t expecting.


3、登录到远程机器不用输入密码,登陆之后会将对方的信息,记录在known_hosts文件中,第一次登陆需要输入yes

# ssh 192.168.75.128   

# ssh slave.localdomain #如果需要主机名登陆,也需要提前登陆一下,因为第一次登陆需要输入yes


4、登陆本机也不需要密码


# ssh-copy-id  -i ~/.ssh/id_rsa.pub 192.168.75.130

# ssh 192.168.75.130

# ssh mater.localdomain



二、192.168.75.128 上做同样的操作

1、在~/.ssh目录下产生公钥与私钥对.

# ssh-keygen  

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:

e4:bb:24:9c:f9:01:a8:80:4d:db:66:5b:47:48:c5:ca root@slave0.localdomain.com

The key‘s randomart image is:

+--[ RSA 2048]----+

|      .o.        |

|     . ..        |

|  .  ...o        |

|.o o .E+         |

|o o = o S        |

| . + + = .       |

|  . . = +        |

|       + o       |

|        o        |

+-----------------+


2、ssh-copy-id 将公钥id_rsa.pub的内容追加到远程机器的 ~/ .ssh/authorized_key.文件中

# ssh-copy-id  -i ~/.ssh/id_rsa.pub 192.168.75.130 

root@192.168.75.130‘s password: 

Now try logging into the machine, with "ssh ‘192.168.75.130‘", and check in:


  .ssh/authorized_keys


to make sure we haven‘t added extra keys that you weren‘t expecting.


3、登录到远程机器不用输入密码,登陆之后会将对方的信息,记录在known_hosts文件中,第一次登陆需要输入yes

# ssh 192.168.75.130  

# ssh master.localdomain #如果需要主机名登陆,也需要提前登陆一下,因为第一次登陆需要输入yes


4、登陆本机也不需要密码,如果有登陆主机名,


# ssh-copy-id  -i ~/.ssh/id_rsa.pub 192.168.75.128

# ssh 192.168.75.128

# ssh slave.localdomain 


参考:http://blog.chinaunix.net/uid-26284395-id-2949145.html


本文出自 “小鱼的博客” 博客,转载请与作者联系!

Linux 双机互信

标签:linux 双机互信 ssh 有效性

原文地址:http://395469372.blog.51cto.com/1150982/1745912

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!