c# – 支持密码短语rsa privatekeys的SSH库
发布时间:2020-12-15 21:39:47 所属栏目:百科 来源:网络整理
导读:我目前正在研究一个小型的Visual C#应用程序 需要一个SSH库. 我已经尝试过DotNetSSH,Renci.SshNet和SharpSsh. Granados SSH库文档很少(至少我发现几乎没有), 所以我跳过这个. 所有这些库都有一个巨大的问题(恕我直言):他们无法打开SSH私有 带密码的密钥. Re
我目前正在研究一个小型的Visual C#应用程序
需要一个SSH库. 我已经尝试过DotNetSSH,Renci.SshNet和SharpSsh. Granados SSH库文档很少(至少我发现几乎没有), 所以我跳过这个. 所有这些库都有一个巨大的问题(恕我直言):他们无法打开SSH私有 Renci.SshNet不支持AES. 使用用户名密码和没有密码短语的私钥连接效果很好 有人已经有同样的问题吗? Thx提前 解决方法
我已成功使用
SSH.NET开源库来使用SSH和SFTP.
这是连接密钥文件密码的代码. public void Connect(string host,int port,string user,string passPhrase,string privateKeyFilePath) { var keyFiles = new[] { new PrivateKeyFile(privateKeyFilePath,passPhrase) }; var methods = new List<AuthenticationMethod>(); methods.Add(new PasswordAuthenticationMethod(user,passPhrase)); methods.Add(new PrivateKeyAuthenticationMethod(user,keyFiles)); var con = new ConnectionInfo(host,port,user,methods.ToArray()); var client = new SshClient(con); client.Connect(); // create an xterm shell var Shell = client.CreateShellStream("xterm",80,24,800,600,1024); // for reading & writing to the shell var reader = new StreamReader(Shell); var writer = new StreamWriter(Shell); // .... client.Disconnect(); } 私钥文件格式 请注意,您的私钥文件必须是OpenSSH格式.如果在记事本中打开密钥文件,则必须在第一行显示“BEGIN RSA PRIVATE KEY”. 如果没有,则使用puttygen将私钥文件转换为OpenSSH格式. >在puttygen中打开私钥>转到“转化”菜单,然后选择“导出OpenSSH密钥”.>将新密钥保存到文件并使用它. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Swift Tutorial(swift 教程) 3:Arrays, Objects, and Class
- PostgreSQL SELECT AS 双引号大小写不敏感处理
- postgresql – 如何在pgAdmin III中查看数据
- c – OpenCV错误:“LINK:致命错误LNK1104:无法打开文件’
- XML解析类NSXMLParser
- XSD (xml Schema Definition)
- 安装VisualDSP++出现Install cannot proceed.Could not fin
- ruby-on-rails – 为rails应用程序创建Rdoc
- oracle – 对同一数据库的相同查询在OAS 10.1.3上给出了不同
- Flex 预载界面美化