c#调用sharpssh连接linux的问题
最近写了个小程序,通过c#连接linux执行一些语句,对输出做一些处理,是通过调用sharpssh实现的,发现几个问题,首先sharpssh连接linux是固定使用22端口的,这个好办,改下sharpssh源码,就可以支持自定义端口,不过我又发现新问题,就是有些linux可以连接,但有些linux连接会报“Algorithm negotiation fail”错误,连接报错的机器都安装了新版的OpenSSH,网上查到的原因是SharpSSH使用diffie-hellman-group1-sha1和diffie-hellman-group-exchange-sha1密钥交换算法,而OpenSSH在6.7p1版本之后默认不再采用以上算法,需要手工添加。
在/etc/sshd_config中添加:
Ciphers aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc,arcfour128,arcfour256,arcfour,blowfish-cbc,cast128-cbc
MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-sha1-96,hmac-md5-96
KexAlgorithms diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256
之后重启sshd服务。
按照以上步骤修改后,确实通过sharpssh可以连接linux,但有一定安全隐患,sharpssh好像2013年以后就没人维护了,请问有没有不修改ssh配置就可以让sharpssh连接安装新版OpenSSH的linux系统的方法,本人刚刚开始学c#,水平有限,复杂的修改就搞不定了,有没有高手可以修改下sharpssh源代码,可以支持新版OpenSSH,或者有其他更好的工具推荐也可以,不胜感激。