栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

转到-如何从PublicKey生成SSH PublicKey指纹,PublicKey的类型可能是[rsa dsa ssh-rsa ssh-dssecdsa]之一

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

转到-如何从PublicKey生成SSH PublicKey指纹,PublicKey的类型可能是[rsa dsa ssh-rsa ssh-dssecdsa]之一

您可能要使用ssh包中的ssh.ParseAuthorizedKey来加载密钥:

https://godoc.org/golang.org/x/crypto/ssh#ParseAuthorizedKey

这将为您提供一个公共密钥,您可以将其称为ssh.FingerprintLegacyMD5以获取指纹(假设在这里您想要md5)。

https://godoc.org/golang.org/x/crypto/ssh#FingerprintLegacyMD5


https://godoc.org/golang.org/x/crypto/ssh#FingerprintSHA256

func main() {    // Read a key from a file in authorized keys file line format    // This could be an rsa.pub file or a line from authorized_keys    pubKeyBytes := []byte(`ssh-rsa AAAABMYKEY...ABC me@myplace.local`)    // Parse the key, other info ignored    pk, _, _, _, err := ssh.ParseAuthorizedKey(pubKeyBytes)    if err != nil {        panic(err)    }    // Get the fingerprint    f := ssh.FingerprintLegacyMD5(pk)    // Print the fingerprint    fmt.Printf("%sn", f)}

提供了两种指纹功能,不确定要使用哪一种。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/387441.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号