Topic "How to Turn Off Server Alerts from Code"

Author Message
nbhanuprakash
[View user's profile]

Joined: 2011-07-25
Posts: 2
Location: Bangalore, India
Hi,

I am using WINSCP to upload files using SFTP. The code was working fine till few days back. Now from the target server there is a server alert fot "Authentication with Pre password --> Using Keyboard Interactive Authentication". Through code there is no way i can select Ok/Cancel for this alert, hence the authentication is failed and connection is getting closed. So how can i turn off Server Alert from my code.
I am using WINSCP Version 4.3.3

Thanks in advance,
Bhanu Prakash N
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
Location: Prague, Czechia
Are you using scripting? Can you post a log file or screenshot of the alert?
_________________
Martin Prikryl
nbhanuprakash
[View user's profile]

Joined: 2011-07-25
Posts: 2
Location: Bangalore, India
Through C# WCF service i am connecting to SFTP server to upload files.

Code Snippet is :
Process winscp = new Process();

remotehost = ConfigurationManager.AppSettings["SFTPServerUser"].ToString();
username = ConfigurationManager.AppSettings["SFTPUserName"].ToString();
password = ConfigurationManager.AppSettings["SFTPPwd"].ToString();


// SFTPExecutable needs to be defined in app.config to point to winscp.com
winscp.StartInfo.FileName = ConfigurationManager.AppSettings["SFTPExecutable"];
if (winscp.StartInfo.FileName == null || winscp.StartInfo.FileName.Length == 0)
{
throw new Exception("from PutSFTP: SFTPExecutable not set in config file");
}

winscp.StartInfo.UseShellExecute = false;
winscp.StartInfo.RedirectStandardInput = true;
winscp.StartInfo.RedirectStandardOutput = true;
winscp.StartInfo.CreateNoWindow = true;
winscp.Start();

LogMessageToFile("Inside UploadFiles....Started winscp process at " + winscp.StartTime.ToString());

//Feed in the script commands
winscp.StandardInput.WriteLine("option batch continue");
winscp.StandardInput.WriteLine("option confirm off");
winscp.StandardInput.WriteLine("open sftp://" + username + ":" + password + "@" + remotehost);
winscp.StandardInput.WriteLine("put " + UploadFile);
winscp.StandardInput.Close();

string output = winscp.StandardOutput.ReadToEnd();
LogMessageToFile("Inside Upload files SFTP ..status of upload --> " + output);

// Wait until WinSCP finishes
winscp.WaitForExit();

bool ftpStatus = (winscp.ExitCode == 0);

Log message is:
batch continue
winscp> option confirm off
confirm off
winscp> open sftp://useranme:pwd$@Server//foldername -hostkey="ssh-rsa 1024 53:da:ad:20:06:4e:fc:bf:9d:4f:6d:72:88:b5:14:26"
Searching for host...
Connecting to host...
Authenticating...
Using username "username".
Authenticating with pre-entered password.
Connection has been unexpectedly closed. Server sent command exit status 0.
Authentication log (see session log for details):
Using username "username".[/url]
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
Location: Prague, Czechia
You need to check the server-side log for reason it is closing the conection.
_________________
Martin Prikryl
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