Share via


Managing Linux computers with SSH from PowerShell

Credits

Thanks to a SSH module made by @ Carlos_Perez

Procedure

Managing SSH hosts is trivial in PowerShell.

1. Install the SSH module

Type the following command to install the module on your system:

iex (New-Object Net.WebClient).DownloadString("https://gist.github.com/darkoperator/6152630/raw/c67de4f7cd780ba367cccbc2593f38d18ce6df89/instposhsshdev")

 

2. Connect to a system and issue commands:

 

$creds = Get-Credential

$ssh = (New-SSHSession -ComputerName 10.1.2.3 -Credential $creds).SessionId

Invoke-SSHCommand -Command 'ls -a' -SessionId $ssh  

 

That's all! You can add any number of SSH commands you wish after that. When done, remember to end the session:

Remove-SSHSession $ssh