如何知道SSH密钥的长度和类型? 如果可能的话,如何将它们放入变量中以便稍后调用?
您应该能够获得以下详细信息:
# check length and type of key
$ key_length=$(ssh-keygen -lf 00.key | awk '{print $1}'); echo $key_length
$ key_type=$(ssh-keygen -lf 00.key | awk '{print $3}'); echo $key_type
$ ssh-keygen -lf 00.key
2048 SHA256:<key_in_base64> no comment (DSA)
$ ssh-keygen -lf 00.key
256 SHA256:<key_in_base64> no comment (ECDSA)
$ ssh-keygen -lf 00.key
2048 SHA256:<key_in_base64> no comment (RSA)
$ ssh-keygen -lf 00.key
00.key is not a public key file.
您还可以输入以下命令:
$ ssh-add -l
The agent has no identities.
$ eval `ssh-agent -s`
Agent pid 12345
$ ssh-add ~/.ssh/my_ssh_key
Identity added: /home/myUSER/.ssh/my_ssh_key My SSH Key
$ ssh-add -l
3072 SHA256:xxxxxxxxxxxxxxxxx/yyyyyyyyyyyyyyyyyy My SSH Key (RSA)
$