I am trying to do the other way around....
public key with the client
and private key in the server
here is the eg: in the example viewer
Demonstrates how to connect to an SFTP server where the server is validated by
matching the public key that it presents against one stored in a file.
public void Run(string serverAddress, int serverPort, string userName, string password, string publicKeyFile)
{
// Instantiate SecureFTPConnection
SecureFTPConnection ftpConnection = new SecureFTPConnection();
// setting server address and credentials
ftpConnection.ServerAddress = serverAddress;
ftpConnection.ServerPort = serverPort;
ftpConnection.UserName = userName;
ftpConnection.Password = password;
// select SFTP
ftpConnection.Protocol = FileTransferProtocol.SFTP;
// turn on server validation and set the public key for the host
ftpConnection.ServerValidation = SecureFTPServerValidationType.Automatic;
ftpConnection.KnownHosts.AddKnownHost(serverAddress, publicKeyFile);
// connect to server
PrintLine("Connecting to server " + serverAddress);
ftpConnection.Connect();
// get the current working directory and files
PrintLine("Files in directory " + ftpConnection.WorkingDirectory + ":");
PrintLines(ftpConnection.GetFiles());
// Shut down client
PrintLine("Closing client");
ftpConnection.Close();
PrintLine("Example complete");
}