Topic "c# winscp.exe sshhostkey?"

Author Message
wiglwagl
[View user's profile]

Joined: 2012-06-12
Posts: 1
hi,

i'm using c# and the winscp.dll.

Code:
try
{
// Setup session options
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = "sername",
UserName = "root",
Password = "123456",
SshHostKey = "ssh-rsa 4711xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
};

using (Session session = new Session())
{
// Connect
session.DisableVersionCheck = true;
session.Open(sessionOptions);

// Upload files
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;

TransferOperationResult transferResult;
transferResult = session.PutFiles(@"d:\toupload\*", "/tmp/", false, transferOptions);

// Throw on any error
transferResult.Check();

// Print results
foreach (TransferEventArgs transfer in transferResult.Transfers)
{
Console.WriteLine("Upload of {0} succeeded", transfer.FileName);
}
}


}
catch (Exception e)
{
Console.WriteLine("Error: {0}", e);

}

The Problem ist, that the SshHostKey is not valid. I have to connect with winscp.exe at the fitst time, now i get the sshhostkey.

QUESTION:
Is it possible to execute the winscp.exe with host, user, pw and get back the sshkey???

Thanks a lot best regrds
ww
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
Location: Prague, Czechia
Please read FAQ, to understand why you should not want to do this:
https://winscp.net/eng/docs/faq_hostkey
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