• 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 ~]$ 
  • 相关阅读:
    centos 添加 composer
    laravel5 缓存的使用
    git 的使用
    php 消息队列 rabbitmq 的安装使用
    vue插件大汇总
    vue 2.0 Gzip打包压缩
    Easy Mock 为啥那么打不开了?
    element ui 打印 表格
    解决 element 日期范围选择问题(只能选择相邻的 连两个月)
    vue router 的路由传参 params 和 query 的 区别
  • 原文地址:https://www.cnblogs.com/Eddyer/p/6514164.html
Copyright © 2020-2023  润新知