一,原理

linux 下的ssh免密登陆设置

 

说明:

A为linux服务器a

B为linux服务器b

每台linux都有ssh的服务端和客户端,linux下的ssh命令就是一个客户端

我们常用ssh协议来进行登陆或者是文件的拷贝,都需要密码

A要免密登陆B:

1,需要在a中执行ssh-keygen生成自己的公钥和私钥,生成的文件在.ssh文件中。

2,需要吧a中的公钥copy到b中的中,b进行授权(把公钥中的信息拷贝到“authorized_keys”文件中)  这里只需要一个命令ssh-copy-id 命令

eg:

[eddy@eddy01 .ssh]$ ssh-keygen                                                     
Generating public/private rsa key pair.
Enter file in which to save the key (/home/eddy/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase):           //直接回车
Enter same passphrase again:               //直接回车
Your identification has been saved in /home/eddy/.ssh/id_rsa.
Your public key has been saved in /home/eddy/.ssh/id_rsa.pub.
The key fingerprint is:
58:e5:f9:58:27:b5:4e:dc:32:ce:6c:eb:56:ac:89:9b eddy@eddy01
The key's randomart image is:
+--[ RSA 2048]----+
|          .   .  |
|         o . o o |
|        . o o B .|
|       o   + O o |
|      . S . . *. |
|             . .o|
|             ..+ |
|            .o+  |
|            Eo.  |
+-----------------+
[eddy@eddy01 .ssh]$ ssh-copy-id eddy02                                             
eddy@eddy02's password: 
Now try logging into the machine, with "ssh 'eddy02'", and check in:

  .ssh/authorized_keys

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

[eddy@eddy01 .ssh]$ ssh eddy02
Last login: Tue Mar  7 12:25:23 2017 from 192.168.145.1
[eddy@eddy02 ~]$ 

 

相关文章:

  • 2021-12-04
  • 2021-10-27
  • 2021-08-26
  • 2021-06-20
  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-25
  • 2021-12-17
  • 2022-01-08
  • 2022-12-23
  • 2022-02-07
  • 2021-08-26
相关资源
相似解决方案