当前位置:编程学习 > C#/ASP.NET >>

利用开源SharpSSH 和 granados制作SSH客户端-[乱码问题],高手请进!

大家好,
   最近想制作一个B/S结构的WEB版DOS。
   其中遇到远程协议(SSH、TELNET)指令执行的问题,因此想借用以上两个开源项目。
问题:
   当我运行开源项目示例时,SSH到服务器后,接收到的返回中,所有中文都是乱码。
请高手赐教。
   

       static void Main(string[] args)
        {
            try
            {
                //Create a new JSch instance
                JSch jsch = new JSch();

                //Prompt for username and server host               
                Console.WriteLine("Please input hostname:");
                String host = Console.ReadLine();
                Console.WriteLine("Please input username:");
                String user = Console.ReadLine();
                Console.WriteLine("Please input password:");
                String pwd = Console.ReadLine();

                //Create a new SSH session
                Session session = jsch.getSession(user, host, 22);

                // username and password will be given via UserInfo interface.
                UserInfo ui = new ShellUserInfo();
                ui.setPassword(pwd);
                session.setUserInfo(ui);

                //Connect to remote SSH server
                session.connect();

                //Open a new Shell channel on the SSH session
                Channel channel = session.openChannel("shell");

                //Redirect standard I/O to the SSH channel
                channel.setInputStream(Console.OpenStandardInput());
                channel.setOutputStream(Console.OpenStandardOutput());

                //Connect the channel
                channel.connect();

                Console.WriteLine("-- Shell channel is connected using the {0} cipher",
                    session.getCipher());

                //Wait till channel is closed
                while (!channel.isClosed())
                {
                    System.Threading.Thread.Sleep(500);
                }

                //Disconnect from remote server
                channel.disconnect();
                session.disconnect();

            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
--------------------编程问答-------------------- --------------------编程问答-------------------- --------------------编程问答-------------------- 高手请帮忙,或者运行下开源代码,麻烦了。别沉了 --------------------编程问答-------------------- 在线等
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,