VMware Cloud Community
BCaldwell2
Contributor
Contributor

PowerCLI & SSH.Net

I was curious if anyone has been able to get SSH.NET to work with powershell and ESXi 5.x? ESXi 5.x appears to require the KeyboardInteractiveConnectionInfo class to connect. However, I'm not familiar enough with .Net to figure out how to make this change when creating the ssh.net object in powershell.

http://www.powershelladmin.com/wiki/SSH_from_PowerShell_using_the_SSH.NET_library

$user = ""

$host = ""

$KeyboardInteractive = New-Object Renci.SshNet.KeyboardInteractiveAuthenticationMethod($user)

$ConnectionInfo = New-Object Renci.SshNet.ConnectionInfo($host,22,$user,$KeyboardInteractive)

$SSH = New-Object Renci.SshNet.SshClient($ConnectionInfo)

$SSH.Connect()

0 Kudos
3 Replies
LucD
Leadership
Leadership

You did first check that the SSH service is running on the ESXi server first I assume ?

See Arne's most recent post on the topic PowerCLI: enable SSH and configure ESXi Firewall

Then a simple

New-SshSession -ComputerName $esx -Username root

should work.

Did you try that ?

Any error messages ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
BCaldwell2
Contributor
Contributor

Hey Luc,

Yep... SSH is enabled. I can connect with Putty.

However, the New-SshSession cmdlet in the module in the article isn't working with ESXi 5.x because KeyboardInteractiveAuthenticationMethod isn't the method the cmdlet is using to connect. From what I understand this changed from ESXi 4.1 to ESXi 5.x. The module works with 4.1 but not 5.x.

If I connect with the New-SshSession cmdlet I receive an error stating the below.

Exception calling "Connect" with "0" argument(s): "No suitable authentication method found to complete authentication."
At line:1 char:19
+ $SshClient.Connect <<<< ()
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

If I use the code I posted in the original post and attempt to create an object for the KeyboardInteractiveAuthenticationMethod class I get the below error.

Exception calling "Connect" with "0" argument(s): "Value cannot be null.
Parameter name: data"
At line:1 char:19
+ $SshClient.Connect <<<< ()
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

0 Kudos
GordonPM
Enthusiast
Enthusiast

HI

Did you ever find a resolution to this?

0 Kudos