ssh - do_convert_from_pkcs8 :/dev/fd/63 is not a recognised public key format

标签 ssh openssl ssh-keygen

我正在尝试使用以下脚本检索我的 PIV key :
getPIVkey.sh

NAME=`security find-certificate | grep PIV | sed 's;keychain:";;g' | sed 's;";;g'`
echo $NAME
ssh-keygen -i -m pkcs8 -f <(security find-certificate -p "$NAME" | openssl x509 -noout -pubkey)

在 Mac OS High Sierra 10.13.4 上。我得到:
./getPIVPub.sh
keychain: PIV-Bill K Brown (piv)
security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.
    unable to load certificate
    140735828857800:error:0906D06C:PEM routines:PEM_read_bio:no start line:/BuildRoot/Library/Caches/com.apple.xbs/Sources/libressl/libressl-22.50.2/libressl/crypto/pem/pem_lib.c:704:Expecting: TRUSTED CERTIFICATE
    do_convert_from_pkcs8: /dev/fd/63 is not a recognised public key format

最佳答案

您的第一个 sed 中似乎缺少一个空格命令,在 keychain: 之间和报价。所以你的命令设置NAME变量应该是

NAME=`security find-certificate | grep PIV | sed 's;keychain: ";;g' | sed 's;";;g'`

随着改进的sed命令,NAME 的(打印的)值不应再以 keychain: 开头但只包含名称。

由于 NAME 中的值错误,第二个security find-certificate命令失败,因此输出 The specified output could not be found in the keychain. .之后执行的命令也会失败。

仅供引用,引用 /dev/fd/63 的原因在问题 Why does process substitution result in a file called /dev/fd/63 which is a pipe? 的答案中进行了解释

关于ssh - do_convert_from_pkcs8 :/dev/fd/63 is not a recognised public key format,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51470544/

相关文章:

c++ - 通过管道与 PuTTY 通信

mongodb - 使用 Robo 3T 连接远程 MongoDB

vim - 从 Mac OS X 通过 SSH 突出显示 PHP 语法

delphi - 我们如何连接网站?收到 SSL 错误 1409442E

php - 找不到 CentOS OpenSSL php_openssl.dll

ssh - `-o` 标志在 `ssh-keygen` 中起什么作用?

linux - 使用隧道通过第二方访问无法访问的远程存储库(在 Eclipse 上)

ssl - Nginx PEM_read_bio_X509 PEM_read_bio :bad end line

ssh - 指纹已被采集 - GIT