• 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 ~]$ 
  • 相关阅读:
    常用正则表达式
    C#链接常见数据库的方法
    [转]hibernate分页原理
    2020hdu多校第一场比赛及补题
    2020hdu多校第四场比赛及补题
    2020hdu多校第五场比赛及补题
    2020hdu多校第三场比赛及补题
    2020hdu多校第二场比赛及补题
    第二次vj团队赛补题
    字符串距离问题
  • 原文地址:https://www.cnblogs.com/Eddyer/p/6514164.html
Copyright © 2020-2023  润新知