Post a reply

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: SSH host key fingerprint "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" does not mat

Do you really have the xx:xx:xx... there?
It's not a valid fingerprint.
See https://winscp.net/eng/docs/faq_hostkey
josenebro

SSH host key fingerprint "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" does not mat

I am using the .NET libraries and I am trying to connect to a server for the first time.
I am using public/private key authentication.
HostName, UserName, Password etc, have been set in memory variables before calling this code
below is my code
try
{
// Setup session options
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = ftpServer,
UserName = ftpUser,
Password = ftpPassword,
//GiveUpSecurityAndAcceptAnySshHostKey = false,
SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx",
SshPrivateKeyPath = PrivateKeyFile,
PortNumber = 22,
SshPrivateKeyPassphrase = PrivateKeyPass
};
/////Here I get the exception?/// Why?

using (Session session = new Session())
{
session.Open(sessionOptions);

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

TransferOperationResult transferResult;
transferResult = session.PutFiles(localfilename, ftpfilename, false, transferOptions);
transferResult.Check();
if (transferResult.IsSuccess)
{
return true;
}
else
{
return false;
}
}
}
catch (Exception e)
{
writeToLog(true, e.Message.ToString());
throw new Exception(e.Message);
}

I get the following error in the call to create the sessing

SSH host key fingerprint "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" does not match pattern /((ssh-rsa|ssh-dss)( |-))?(\d+ )?([0-9a-f]{2}(:|-)){15}[0-9a-f]{2}(;((ssh-rsa|ssh-dss)( |-))?(\d+ )?([0-9a-f]{2}(:|-)){15}[0-9a-f]{2})*/

What am I doing wrong?