Topic "Error when I open a session"

Author Message
BlackAlpha
[View user's profile]

Joined: 2016-05-11
Posts: 1
Location: Reunion Island
Hello,

I want to connect to a SFTP to upload a file with C# and WinScp but i'm having a problem, i got this error ah the "session.open()" line :
Quote:
Connection has been unexpectedly closed. Server sent command exit status 0.



My code is :
Code:
try
            {
                var sessionsOptions = new SessionOptions
                {
                    Protocol = Protocol.Sftp,
                    HostName = Settings.Default.p_credHost,
                    UserName = Settings.Default.p_credName,
                    Password = Settings.Default.p_credPass,
                    PortNumber = 22,
                    GiveUpSecurityAndAcceptAnySshHostKey = true
                };

                using (var session = new Session())
                {
                    session.Open(sessionsOptions);
                    var transferOptions = new TransferOptions {TransferMode = TransferMode.Binary};

                    session.PutFiles(localFile, string.Concat("/", newFile), true, transferOptions);
                }

            }
            catch (SessionException error)
            {
                MessageBox.Show(string.Concat("FTP Error : ", error.Message));
            }


Even if I set an SSH key, I still get the same error, do you have an idea why ?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24553
Location: Prague, Czechia
Are you able to connect with any (even GUI) SFTP/SSH client?

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License