如何在C#应用程序中使用ssh-rsa和SSH2 PUBLIC KEY [英] How to use ssh-rsa and SSH2 PUBLIC KEY in a C# application

查看:554
本文介绍了如何在C#应用程序中使用ssh-rsa和SSH2 PUBLIC KEY的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在文本文件(.txt)中有一个ssh-rsa和SSH2 PUBLIC KEY,如何使用它连接到给定的服务器?示例代码非常有用。



我尝试过:



我已经尝试了以下代码,但我收到错误Algoritham协商失败。



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;
}

推荐答案

这不是普遍通行证。



给定服务器确定如何交换/使用这些密钥。



你从开源样本数据库中取出一些你没有的东西了解并期望其他人为您实施。
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.


这篇关于如何在C#应用程序中使用ssh-rsa和SSH2 PUBLIC KEY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆