Reputation: 162
How can one create a PowerShell session from a Windows10 VM to an RHEL8 VM in Azure without storing the SSH key on disk? Looks like the New-PSSession
cmdlet doesn't accept SSH key as string.
$pssession = New-PSSession -Name RHELSession -HostName <> -Port 22 -Subsystem powershell -UserName <> -KeyFilePath .\<>.pem -SSHTransport
Invoke-Command -Session $pssession -ScriptBlock {hostname}
Can one Get-AzSshKey or Get-AzKeyVaultSecret and provide the key from memory without storing the .pem file on disk?
(Get-AzSshKey -ResourceGroupName <> -Name <>).publicKey
Upvotes: 0
Views: 521
Reputation: 5341
You are correct, New-PSSession
currently (pwsh v7.1) only allows loading an SSH key from a file. There have been some requests to add that functionality, but starting SSH sessions using the PSSession
cmdlets is still very limited.
For now, using the basic ssh.exe
is more straightforward and should be able to do what you're looking for.
Upvotes: 1