• 验证远程主机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 生成的指纹是相同的。

  • 相关阅读:
    HDU 6125
    HDU 6129
    Super Jumping! Jumping! Jumping!
    HDU 1040 As Easy As A+B(排序)
    VS2015转VS2008
    HDU 1329 Hanoi Tower Troubles Again!(乱搞)
    HDU 1062 Text Reverse(字符串)
    HDU 1013 Digital Roots(字符串)
    HDU 1003 Max Sum(动态规划)
    HDU 1203 I NEED A OFFER!(01背包)
  • 原文地址:https://www.cnblogs.com/litifeng/p/14770756.html
Copyright © 2020-2023  润新知