一个 PowerShell SSH 可以不在磁盘上存储密钥吗?

Can one PowerShell SSH without storing key on disk?

如何在 Azure 中创建从 Windows10 VM 到 RHEL8 VM 的 PowerShell 会话而不将 SSH 密钥存储在磁盘上? 看起来像 New-PSSession cmdlet 不接受 SSH 密钥作为字符串。

$pssession = New-PSSession -Name RHELSession -HostName <> -Port 22 -Subsystem powershell -UserName <> -KeyFilePath .\<>.pem -SSHTransport
Invoke-Command -Session $pssession -ScriptBlock {hostname}

可以 Get-AzSshKey or Get-AzKeyVaultSecret 并从内存中提供密钥而不将 .pem 文件存储在磁盘上吗?

(Get-AzSshKey -ResourceGroupName <> -Name <>).publicKey

你是对的,New-PSSession 目前 (pwsh v7.1) 只允许从文件加载 SSH 密钥。已经 some requests 添加了该功能,但是使用 PSSession cmdlet 启动 SSH 会话仍然非常有限。

目前,使用基本的 ssh.exe 更直接,应该能够满足您的需求。