Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: VM vs production

It's unlikely that the host key is the culprit. Post logs from GUI for comparison.

Also enable password logging and compare GUI and code logs to double check that you use the same password in both cases.
francesco84mantovani@gmail.com

VM vs production

Yes, I'm connecting to two different servers. That's why you have successful login to VM and fails to the production server.
Yes, I can successfully connect to the production using WinSCP GUI but using the PowerShell code of your guides it fails.
Do you think it can be related to the
SshHostKeyFingerprint
being different?
Is there a way I can change the
SshHostKeyFingerprint
from
ssh-ed25519
to
rsa2
and test?

Because that is the only difference between the VM and the production
martin

Re: PowerShell code in documentation is not working

But those logs shows connections to different servers. Or what is your VM? I've understood that it is a machine, from where you can connect. Or did you use the VM as a test server? Can you connect to your production server anyhow? In WinSCP GUI? From any other local machine?
francesco84mantovani@gmail.com

Done already

I already set
$session.SessionLogPath
and the logs are in my previous post.

Thank you
martin

Re: PowerShell code in documentation is not working

Set Session.SessionLogPath and post logs from both environments.
francesco84mantovani@gmail.com

WinSCP portable version

I have download the portable version of WinSCP and I pointed the Add-Type -Path to the \netstandard2.0\WinSCPnet.dll and \net40\WinSCPnet.dll. Still failing for both :(

The error in PowerShell is always the same:
Exception calling "Open" with "1" argument(s): "Connection has been unexpectedly closed. Server sent command exit status 0.

Authentication log (see session log for details):
Using username "a***1".
Access denied.
Authentication failed."
At C:\Users\FMV\Documents\test.ps1:18 char:5
+     $session.Open($sessionOptions)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SessionRemoteException

But the exact same code works on my Test VM environment.
Where can be the problem?
francesco84mantovani@gmail.com

Basic code and logs

Hello,

I have a version of the code I'm using:
Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"
 
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
    Protocol = [WinSCP.Protocol]::Sftp
    HostName = "1*.***.***.*0"
    UserName = "a*****1"
    Password = "m*********9"
    SshHostKeyFingerprint = "ssh-ed25519 255 eeDKU******************************UNg="
}
 
$session = New-Object WinSCP.Session
$session.SessionLogPath = "C:\Users\FMV\Documents\logging.log"
 
try
{
    # Connect
    $session.Open($sessionOptions)
    # Your code
   
    # From VM to Laptop
    $session.GetFiles("full***********.csv", "C:\Users\fmv\Downloads\" )
}
finally
{
    $session.Dispose()
}


And in attach the logs.
I was able to test this code on a VM that I created especially for this issue. Everything works.

VM TEST:
– WinSCP Version 5.19.2
– rsa2
– Command: working
– Powershell Script: working

PROD:
– WinSCP Version 5.17.10
– ssh-ed25519
– Command: working
– PowerShell Script: fails

Can the hotkey be the problem?
francesco84mantovani@gmail.com

Version 5.17.10

I forgot to mention that I'm on I'm on version 5.17.10
francesco84mantovani@gmail.com

PowerShell code in documentation is not working

Hello,

I've recently try to run the PowerShell code that is mentioned in your documentation: https://winscp.net/eng/docs/library_powershell#example

It fails abruptly.

Is there a way to increase the logs for PowerShell?