ssh与关键内容而不是identity_file

而不是ssh -i mykey.pem我想将ssh -i mykey.pem内容 mykey.pem给ssh命令。

这有可能吗?

背景: mykey.pem以encryption方式存储。 我想解密它(在一个CI工具),并将其传递给SSH。 对其进行解密并将path传递给解密的密钥将使具有光盘访问权的人可以访问该密钥。

你可以在bash中使用进程replace (伪文件),如:

ssh -i <( some command to generate file contents ) host

例子:

ssh -i <( cat /tmp/key.id ) host
ssh -i <( echo key contents ) host

你可以在这里阅读更多关于https://en.wikipedia.org/wiki/Process_substitution

编辑:

第二次阅读你的问题后,我不知道这是你想要的