Using Powershell version 3:
PS C:\Windows\system32> $PSVersionTable
Name Value
---- -----
WSManStackVersion 3.0
PSCompatibleVersions {1.0, 2.0, 3.0}
SerializationVersion 1.1.0.1
BuildVersion 6.2.9200.16398
PSVersion 3.0
CLRVersion 4.0.30319.1
PSRemotingProtocolVersion 2.2
---- -----
WSManStackVersion 3.0
PSCompatibleVersions {1.0, 2.0, 3.0}
SerializationVersion 1.1.0.1
BuildVersion 6.2.9200.16398
PSVersion 3.0
CLRVersion 4.0.30319.1
PSRemotingProtocolVersion 2.2
PS C:\Windows\system32> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
3 0 -1 -1
----- ----- ----- --------
3 0 -1 -1
Download SSH-Session module from:
In Download Section:
Extract SSH-SessionsPSv3.zip and this creates:
C:\Downloads\SSH-SessionsPSv3.zip\SSH-Sessions
Get the Module Paths:
PS C:\Windows\system32> $env:PSModulePath
C:\Users\rumman\Documents\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
This is module extention path: C:\Users\rumman\Documents\WindowsPowerShell\Modules
Copy "C:\Downloads\SSH-SessionsPSv3\SSH-Sessions" To "C:\Users\rumman\Documents\WindowsPowerShell\Modules"
Now, in shell prompt, use the following command to ensure that the module is available:
PS C:\Windows\system32> Get-Module *ssh*
ModuleType Name ExportedCommands
---------- ---- ----------------
Script SSH-Sessions {ConvertFrom-SecureToPlain, Enter-SshSession, Get-SshSession,
PS C:\Windows\system32> Get-Command *ssh*
---------- ---- ----------------
Script SSH-Sessions {ConvertFrom-SecureToPlain, Enter-SshSession, Get-SshSession,
PS C:\Windows\system32> Get-Command *ssh*
CommandType Name ModuleName
----------- ---- ----------
Function Enter-SshSession SSH-Sessions
Function Get-SshSession SSH-Sessions
Function Invoke-SshCommand SSH-Sessions
Function New-SshSession SSH-Sessions
Function Remove-SshSession SSH-Sessions
----------- ---- ----------
Function Enter-SshSession SSH-Sessions
Function Get-SshSession SSH-Sessions
Function Invoke-SshCommand SSH-Sessions
Function New-SshSession SSH-Sessions
Function Remove-SshSession SSH-Sessions
Import Module:
PS C:\Users\rumman> Import-Module SSH-Sessions
Import-Module : Could not load file or assembly
'file:///C:\Users\rumman\Documents\WindowsPowerShell\Modules\SSH-Sessions\Renci.SshNet.dll' or one of its
dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
At line:1 char:1
+ Import-Module SSH-Sessions
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Import-Module], FileLoadException
+ FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand
'file:///C:\Users\rumman\Documents\WindowsPowerShell\Modules\SSH-Sessions\Renci.SshNet.dll' or one of its
dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
At line:1 char:1
+ Import-Module SSH-Sessions
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Import-Module], FileLoadException
+ FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand
I faced the above issue and what I did unblocking the file.
Go to C:\Users\rumman\Documents\WindowsPowerShell\Modules\SSH-Sessions
There are 3 files:
- Renci.SshNet.dll
- SSH-Sessions.psd1
- SSH-Sessions.psm1
For each file, right-click -> Properties -> Unblock
Then, load the module again:
PS C:\Users\rumman> Import-Module SSH-Sessions
PS C:\Users\rumman>
PS C:\Users\rumman>
Verify SSH Connection:
PS C:\Users\rumman> New-SSHSession -ComputerName "10.0.0.16" -Username "postgres"
No key provided. Enter SSH password for postgres: ******
Successfully connected to 10.0.0.16
PS C:\Users\rumman> Get-Session
Successfully connected to 10.0.0.16
PS C:\Users\rumman> Get-Session
PS C:\Users\rumman> Get-SSHSession
ComputerName Connected
------------ ---------
10.0.0.16 True
------------ ---------
10.0.0.16 True
PS C:\Users\rumman> Remove-SSHSession -ComputerName "10.0.0.16"
10.0.0.16 should now be disconnected and disposed.
10.0.0.16 should now be disconnected and disposed.
Setup Password-less SSH:
Download Putty.exe and Puttygen.exe. One of the sites for this:
There are lots of sites available to describe the steps to use puttygen to setup password-less ssh.
For example,
I saved the private key at C:\putty\private_key.ppk
And also use the menu conversion->export OpenSSH
and save it as exported_openssh_key
This key is usable for other application.
When password-less ssh is working form Putty, now try from powershell:
PS C:\Users\rumman> New-SSHSession -ComputerName "10.0.0.16" -UserName "postgres" -KeyFile C:\putty\exported_openssh_key
Key file specified. Will override password. Trying to read key file...
PS C:\Users\rumman> Get-SSHSession
ComputerName Connected
------------ ---------
10.0.0.16 True
------------ ---------
10.0.0.16 True
Thanks for sharing this information Freyr Energy was founded on the principles of making solar energy affordable and accessible for everyone. In order to make adoption of solar energy a reality at the grass-root level, we have identified that consumer awareness, affordability and accessibility play an integral role. With our innovative platform, SunPro+, our extensive channel-partner network and our efficient service we ensure that these three factors are addressed to make sure your venture into solar energy is hassle-free. Best solar company in Hyderabad-freyr
Thanks for sharing this information KSAC is one of the most trusted multi-specialty Ayurvedic hospitals in India. For over two decades, we provides 100% Evidence based Treatments for diseases, Naturally.Best Ayurveda Hospital in Hyderabad, Bengalore, India