Posh-SSH icon indicating copy to clipboard operation
Posh-SSH copied to clipboard

New-SSHSession does not work in NonInteractive mode

Open markallisongit opened this issue 8 years ago • 2 comments

I am running New-SSHSession on a build server (VSTS) and this runs PowerShell steps in -Noninteractive mode. This causes my Pester tests which work fine on my dev machine to fail on the build server with:


2017-12-12T15:53:05.2873148Z Describing Linux Container tests
2017-12-12T15:53:36.0097374Z New-SSHSession : Windows PowerShell is in NonInteractive mode. Read and Prompt functionality is not available.
2017-12-12T15:53:36.0097374Z At line:52 char:17
2017-12-12T15:53:36.0097374Z + ...     $sesh = New-SSHSession -ComputerName $DockerHost -Credential $cre ...
2017-12-12T15:53:36.0097374Z +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2017-12-12T15:53:36.0097374Z     + CategoryInfo          : InvalidOperation: (Renci.SshNet.SshClient:SshClient) [New-SSHSession], PSInvalidOperatio 
2017-12-12T15:53:36.0097374Z    nException
2017-12-12T15:53:36.0097374Z     + FullyQualifiedErrorId : SSH.NewSshSession

markallisongit avatar Dec 12 '17 16:12 markallisongit

More than likely it is https://github.com/darkoperator/Posh-SSH/blob/master/PoshSSH/PoshSSH/NewSessionBase.cs#L413 if it is that and -AcceptKey or -Force do not work then I would need to re-engineer the session creations and SCP cmdlets and do to it being a mayor version since it would be a big change.

darkoperator avatar Dec 12 '17 16:12 darkoperator

Thanks, they both worked fine. The -Force gave me warnings WARNING: Host key is not being verified since Force switch is used. and -AcceptKey didn't so I went with -AcceptKey. Great work!

markallisongit avatar Dec 13 '17 09:12 markallisongit