zoukankan      html  css  js  c++  java
  • 验证远程主机SSH指纹

    远程主机指纹的作用:用于验证远程主机确实是我以前连接过的主机,而不是被DNS劫持的主机。

    远程主机:ubuntu20.04系统

    本地:wsl 2 的debian 10系统

    所谓的主机指纹:把远程主机的公钥用一种hash算法输出一个较短的数串。

    这就涉及到2个材料:1、远程主机的公钥。2、双方公用的哈希函数。

    本文远程主机公钥是:椭圆算法生成的公钥,名称是:ssh_host_ecdsa_key.pub

    哈希函数是:sha256

    开始验证:

    1、现在远程主机运行: ssh-keygen -E sha256 -lf ssh_host_ecdsa_key.pub 

    生成远程主机的指纹:

    256 SHA256:1G4x9S7Ymt2QrAu0mohEmvwbV8tGBGqBlGtX+Nac2uI root@remotehost (ECDSA)

    查看ssh-keygen --help 得知:  ssh-keygen -l [-v] [-E fingerprint_hash] [-f input_keyfile] 

     -l      Show fingerprint of specified public key file. 
     -f filename  Specifies the filename of the key file.
     -E fingerprint_hash  Specifies the hash algorithm used when displaying key fingerprints.  Valid options are: “md5” and “sha256”.  The default is “sha256”.

    2、使用ssh-keyscan扫描远程主机,获取公钥,并用相同的哈希函数计算一下:

    ssh-keyscan.exe -t ECDSA -p 22 12.12.12.12(远程ip) | ssh-keygen.exe -E sha256 -lf -

    输出:

    # 12.12.12.12:22 SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.2
    256 SHA256:1G4x9S7Ymt2QrAu0mohEmvwbV8tGBGqBlGtX+Nac2uI 12.12.12.12 (ECDSA)

    3、可以看到 1 和 2 生成的指纹是相同的。

  • 相关阅读:
    ggplot2 上篇
    R笔记1
    读书笔记 第2章 数据挖掘概述
    读书笔记 数据化营销
    [LeetCode] 172. 阶乘后的零
    [LeetCode] 171. Excel表列序号
    [LeetCode] 169. 求众数
    知乎使用selenium反爬虫的解决方案
    [LeetCode] 168. Excel表列名称
    [LeetCode] 167. 两数之和 II
  • 原文地址:https://www.cnblogs.com/litifeng/p/14770756.html
Copyright © 2011-2022 走看看