zoukankan      html  css  js  c++  java
  • SSH密钥对登录的原理和实践

    1、ssh密钥对登录的基本思路是:要登录谁,就把公钥放到谁身上,就可以授权登录谁。

    2、本地登录设备称为ssh客户端,被登录的设备称为ssh服务器。

    3、原理图描述如下:

    4、SSH的公钥分为openssh格式和IETF格式。

         其中puttygen.exe生成的是IETF格式,ssh-keygen生成的是openssh格式,xshell生成的格式则可选。

    5、产生秘钥对的工具软件。

    windows系统:

    (1)puttygen.exe

    (2) xshell工具软件

    Linux系统:

    ssh-keygen -t rsa 

     6、python代码自动化登录设备使用paramiko库进行ssh登录。对于交换机、路由器等网络设备,则使用ncclient库进行连接控制。

    参考:http://www.cnblogs.com/gannan/archive/2012/02/06/2339883.html

     7、xshell 生成秘钥的过程。

          

    8. 通过linux服务器生成ssh 密钥对的流程如下:

    [root@localhost ~]# ssh-keygen -t rsa
    Generating public/private rsa key pair.
    Enter file in which to save the key (/root/.ssh/id_rsa): 
    Created directory '/root/.ssh'.
    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:
    b8:bb:65:c6:cc:53:92:18:bf:3f:52:65:34:9f:98:dc root@localhost.localdomain
    The key's randomart image is:
    +--[ RSA 2048]----+
    | |
    | o |
    | . o * . |
    | = . * E |
    | o S .o |
    | = +. |
    | . X. |
    | =.o. |
    | o. ... |
    +-----------------+
    [root@localhost ~]#

    根据上述流程,生成的秘钥对是id_rsa. 其中以.pub开头的就是公钥(id_rsa.pub),另外一个(id_rsa)就是公钥

     9、查看密钥对中文件内容。

    私钥文件内容:

    公钥文件内容: (右侧有省略,原文太长)

     
     
  • 相关阅读:
    hdu 母牛的故事 递推题
    并查集
    又是矩阵 Uva上的一道 经典题目
    poj 3233 矩阵幂取模
    electronvue + elementui构建桌面应用
    主板cmos 映射表
    高级配置与电源接口 acpi 简介
    警告不能读取 AppletViewer 属性文件的解决方法
    高级 Synth(转载)
    vbs 查看硬件信息代码
  • 原文地址:https://www.cnblogs.com/licheng/p/8372528.html
Copyright © 2011-2022 走看看