Skip to content
Advertisement

Powershell commands on remote machine via openSSH

I am trying to connect to a windows machine from a linux machine via openSSH and run some powershell commands on windows box. I cannot install powershell on linux box due to some restrictions.

Manually launching openSSH from linux and then running commands is working perfectly.

I am trying to do same thing in Java, but the problem is that I am not seeing output of powershell commands ran.

Below is the code to reproduce the same:

JavaScript

Advertisement

Answer

interactive modes don’t work nice with scripts and codes and are not recommended. It’s better to use some existing ssh framework like jsch to connect, which are available as open source maven dependencies.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement