Powershell Invoke-Command SSH pem key connection Error: subsystem request failed on channel 0

75 Views Asked by At

I am new to Powershell scripting. Currently, I am trying to send a command via SSH with a PEM private key for authentication. I am able to connect via SSH fine with this key.

However, when I tried to use the Invoke-Command provided by Powershell with the below command

Invoke-Command -HostName '[email protected]' -KeyFilePath key.pem -ScriptBlock { ls }

I keep getting this error:

subsystem request failed on channel 0

From what I have searched, this error is mainly caused by no authentication or invalid command. However, I am able to log in via SSH (key should be correct) and the remote program is running Linux (ls command should be acceptable?). Any help on this error would be appreciated!

0

There are 0 best solutions below