darkoperator / Posh-SSH

PowerShell Module for automating tasks on remote systems using SSH
BSD 3-Clause "New" or "Revised" License
985 stars 227 forks source link

Set-SCPItem : Could not load file or assembly 'Renci.SshNet, Version=2017.0.0.0 #461

Open dkirby-ms opened 2 years ago

dkirby-ms commented 2 years ago

We are installing Posh-SSH from gallery using Install-Module Posh-SSH and hitting this error when using Set-SCPItem. This has been working fine for months until this week we started seeing this. When I check the version of the Renci.SshNet.dll in the assembly path it shows version 2020 not 2017.

`PS C:\ArcBox> Get-InstalledModule -Name Posh-SSH

Version Name Repository Description


3.0.2 Posh-SSH PSGallery Provide SSH and SCP functionality for executing commands against remote hosts.

PS C:\ArcBox> Update-Module Posh-SSH

PS C:\ArcBox> [System.AppDomain]::CurrentDomain.GetAssemblies() | ? { $_.Location -like 'ssh' }

GAC Version Location


False v4.0.30319 C:\Program Files\WindowsPowerShell\Modules\Posh-SSH\3.0.2\Assembly\Newtonsoft.Json.dll
False v4.0.30319 C:\Program Files\WindowsPowerShell\Modules\Posh-SSH\3.0.2\Assembly\Renci.SshNet.dll
False v4.0.30319 C:\Program Files\WindowsPowerShell\Modules\Posh-SSH\3.0.2\Assembly\SshNet.Security.Cryptography.dll
False v4.0.30319 C:\Program Files\WindowsPowerShell\Modules\Posh-SSH\3.0.2\PoshSSH.dll

PS C:\ArcBox> Set-SCPItem -ComputerName $CentOSVmIp -Credential $linCreds -Destination "/home/$nestedLinuxUsername" -Path "$agentScript\installArcAgentModifiedCentOS.sh" -Force

Set-SCPItem : Could not load file or assembly 'Renci.SshNet, Version=2017.0.0.0, Culture=neutral, PublicKeyToken=1cee9f8bde3db106' or one of its dependencies. The system cannot find the file specified. At line:1 char:1

`

image

MVKozlov commented 2 years ago

Try import-module posh-ssh -verbose, it looks like you have other version somewhere. And please try to search for renci dll across drive c:

dkirby-ms commented 2 years ago

I searched across C drive and it turns up in WinSxS but nowhere else. C:\Windows\WinSxS\amd64_renci.sshnet_31bf3856ad364e35_10.0.20348.1_none_5d0b9d71a320ef64\Renci.SshNet.dll

' PS C:\ArcBox> Import-Module Posh-SSH -verbose VERBOSE: Importing cmdlet 'Get-SCPItem'. VERBOSE: Importing cmdlet 'Get-SFTPItem'. VERBOSE: Importing cmdlet 'Get-SSHJsonKnowHost'. VERBOSE: Importing cmdlet 'New-SFTPSession'. VERBOSE: Importing cmdlet 'New-SSHMemoryKnownHost'. VERBOSE: Importing cmdlet 'New-SSHSession'. VERBOSE: Importing cmdlet 'Set-SCPItem'. VERBOSE: Importing cmdlet 'Set-SFTPItem'. VERBOSE: Importing function 'Convert-SSHRegistryToJSonKnownHost'. VERBOSE: Importing function 'Get-PoshSSHModVersion'. VERBOSE: Importing function 'Get-SFTPChildItem'. VERBOSE: Importing function 'Get-SFTPContent'. VERBOSE: Importing function 'Get-SFTPLocation'. VERBOSE: Importing function 'Get-SFTPPathAttribute'. VERBOSE: Importing function 'Get-SFTPSession'. VERBOSE: Importing function 'Get-SSHPortForward'. VERBOSE: Importing function 'Get-SSHRegistryKnownHost'. VERBOSE: Importing function 'Get-SSHSession'. VERBOSE: Importing function 'Get-SSHTrustedHost'. VERBOSE: Importing function 'Invoke-SSHCommand'. VERBOSE: Importing function 'Invoke-SSHCommandStream'. VERBOSE: Importing function 'Invoke-SSHStreamExpectAction'. VERBOSE: Importing function 'Invoke-SSHStreamExpectSecureAction'. VERBOSE: Importing function 'Invoke-SSHStreamShellCommand'. VERBOSE: Importing function 'Move-SFTPItem'. VERBOSE: Importing function 'New-SFTPFileStream'. VERBOSE: Importing function 'New-SFTPItem'. VERBOSE: Importing function 'New-SFTPSymlink'. VERBOSE: Importing function 'New-SSHDynamicPortForward'. VERBOSE: Importing function 'New-SSHLocalPortForward'. VERBOSE: Importing function 'New-SSHRemotePortForward'. VERBOSE: Importing function 'New-SSHShellStream'. VERBOSE: Importing function 'New-SSHTrustedHost'. VERBOSE: Importing function 'Remove-SFTPItem'. VERBOSE: Importing function 'Remove-SFTPSession'. VERBOSE: Importing function 'Remove-SSHSession'. VERBOSE: Importing function 'Remove-SSHTrustedHost'. VERBOSE: Importing function 'Rename-SFTPFile'. VERBOSE: Importing function 'Set-SFTPContent'. VERBOSE: Importing function 'Set-SFTPLocation'. VERBOSE: Importing function 'Set-SFTPPathAttribute'. VERBOSE: Importing function 'Start-SSHPortForward'. VERBOSE: Importing function 'Stop-SSHPortForward'. VERBOSE: Importing function 'Test-SFTPPath'. '

darkoperator commented 2 years ago

cant seems to replicate it but if possible try removing the current version and install 3.0.1, on what version of Windows are you having the issue, currently testing on Windows 11

darkoperator commented 2 years ago

just pushed a new binary, try version 3.0.4

dkirby-ms commented 2 years ago

Did you mean 3.0.3? Not seeing a 3.0.4

dkirby-ms commented 2 years ago

I can confirm 3.0.3 resolves the issue. Thanks for the quick turnaround.

darkoperator commented 2 years ago

Yes, sorry for the typo

Sent from my iPhone

On May 20, 2022, at 12:44 PM, Dale Kirby @.***> wrote:

 Did you mean 3.0.3? Not seeing a 3.0.4

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.

MVKozlov commented 2 years ago

@darkoperator what's the catch ?

darkoperator commented 2 years ago

VS compiled 2 binaries and I pushed the none netstandard one

Sent from my iPhone

On May 20, 2022, at 1:05 PM, Max Kozlov @.***> wrote:

 @darkoperator what's the catch ?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.