小编Val*_*gul的帖子

使用ASP.NET的webapp中的SSH终端

您好我创建了一个具有类似Putty的SSH终端的webapp.我使用SSH库作为处理ssh流的方法.但是有一个问题.我可以登录到Cisco 2950并输入命令,但它会混乱并且在一行中.此外,当我尝试"conf t"时,它进入配置终端,但是你不能做任何事情,这会弹出"Line有无效的自动命令"?".

这是我到目前为止的代码:

这是与库交互的SSH.c.

public class SSH
{
    public string cmdInput { get; set; }

    public string SSHConnect()
    {
        var PasswordConnection = new PasswordAuthenticationMethod("username", "password");
        var KeyboardInteractive = new KeyboardInteractiveAuthenticationMethod("username");
        // jmccarthy is the username
        var connectionInfo = new ConnectionInfo("10.56.1.2", 22, "username", PasswordConnection, KeyboardInteractive);
        var ssh = new SshClient(connectionInfo);

        ssh.Connect();
        var cmd = ssh.CreateCommand(cmdInput);
        var asynch = cmd.BeginExecute(delegate(IAsyncResult ar)
        {
            //Console.WriteLine("Finished.");
        }, null);

        var reader = new StreamReader(cmd.OutputStream);
        var myData = "";

        while (!asynch.IsCompleted)
        {
            var result …
Run Code Online (Sandbox Code Playgroud)

c# asp.net ssh webforms

1
推荐指数
1
解决办法
4743
查看次数

标签 统计

asp.net ×1

c# ×1

ssh ×1

webforms ×1