问题描述
大家好,最近想制作一个B/S结构的WEB版DOS。其中遇到远程协议(SSH、TELNET)指令执行的问题,因此想借用以上两个开源项目。问题:当我运行开源项目示例时,SSH到服务器后,接收到的返回中,所有中文都是乱码。请高手赐教。staticvoidMain(string[]args){try{//CreateanewJSchinstanceJSchjsch=newJSch();//PromptforusernameandserverhostConsole.WriteLine("Pleaseinputhostname:");Stringhost=Console.ReadLine();Console.WriteLine("Pleaseinputusername:");Stringuser=Console.ReadLine();Console.WriteLine("Pleaseinputpassword:");Stringpwd=Console.ReadLine();//CreateanewSSHsessionSessionsession=jsch.getSession(user,host,22);//usernameandpasswordwillbegivenviaUserInfointerface.UserInfoui=newShellUserInfo();ui.setPassword(pwd);session.setUserInfo(ui);//ConnecttoremoteSSHserversession.connect();//OpenanewShellchannelontheSSHsessionChannelchannel=session.openChannel("shell");//RedirectstandardI/OtotheSSHchannelchannel.setInputStream(Console.OpenStandardInput());channel.setOutputStream(Console.OpenStandardOutput());//Connectthechannelchannel.connect();Console.WriteLine("--Shellchannelisconnectedusingthe{0}cipher",session.getCipher());//Waittillchannelisclosedwhile(!channel.isClosed()){System.Threading.Thread.Sleep(500);}//Disconnectfromremoteserverchannel.disconnect();session.disconnect();}catch(Exceptione){Console.WriteLine(e);}}
解决方案
解决方案二:
该回复于2012-07-12 11:47:40被版主删除
解决方案三:
解决方案四:
高手请帮忙,或者运行下开源代码,麻烦了。别沉了
解决方案五:
在线等
解决方案六:
楼主最后怎么解决啦?