How to Turn Off Server Alerts from Code

Advertisement

nbhanuprakash
Joined:
Posts:
2
Location:
Bangalore, India

How to Turn Off Server Alerts from Code

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

Reply with quote

Advertisement

nbhanuprakash
Joined:
Posts:
2
Location:
Bangalore, India

Re:Re;Hpw to Turn Off Server Alerts from Code

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]

Reply with quote

martin
Site Admin
martin avatar

Re:Re;Hpw to Turn Off Server Alerts from Code

You need to check the server-side log for reason it is closing the conection.

Reply with quote

Advertisement

You can post new topics in this forum