Click here to Skip to main content
15,891,726 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an ssh-rsa and SSH2 PUBLIC KEY in text files(.txt), how can i use it to connect to a given server? A sample code will be very usefull.

What I have tried:

I have tried the following code, but i am getting the error Algoritham negotiation fail.

try
{
	string pkeypath = @"C://boa/xxx.key";
	Tamir.SharpSsh.Sftp objSFTP = new Tamir.SharpSsh.Sftp(ConfigurationManager.AppSettings["Server"].ToString(), ConfigurationManager.AppSettings["Username"].ToString(), ConfigurationManager.AppSettings["APassword"].ToString());
	objSFTP.AddIdentityFile(pkeypath);
	objSFTP.Connect();
}
catch (Exception ex)
{
	string x = ex.Message;
}
Posted
Updated 20-Feb-19 4:25am
v2

1 solution

It's not a "universal pass".

A "given" server determines how these keys are exchanged / used.

You pulled something out of a "open source samples database" that you don't understand and expect someone else to implement it for you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900