关于SSH,PUTTY Security Alert

本文介绍了一种通过使用PLINK.EXE解决远程连接问题的方法,通过执行特定的命令序列,可以确保连接稳定且不会遇到常见的连接中断问题。该方法适用于需要频繁进行远程操作的场景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

用plink.exe的方法,首先执行一次,就会没有这个问题出现

DoDos("", "echo y;exit | C:\\Putty\\PLINK.EXE -l root 192.168.60.1:/ \"exit\" >> TempLog.txt", "exit");

 

public string DoDos(string comd1, string comd2, string comd3)
        {
            string output = null;
            Process p = new Process();//创建进程对象
            p.StartInfo.FileName = "cmd.exe";//设定需要执行的命令
            // startInfo.Arguments = "/C " + command;//“/C”表示执行完命令后马上退出  
            p.StartInfo.UseShellExecute = false;//不使用系统外壳程序启动
            p.StartInfo.RedirectStandardInput = true;//可以重定向输入  
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.RedirectStandardError = true;
            p.StartInfo.CreateNoWindow = true;//不创建窗口
            p.Start();
            // string comStr = comd1 + "&" + comd2 + "&" + comd3;
            p.StandardInput.WriteLine(comd1);
            p.StandardInput.WriteLine(comd2);
            Thread.Sleep(100);
            p.StandardInput.WriteLine(comd3);
            p.WaitForExit();

            output = p.StandardOutput.ReadToEnd();
            output += p.StandardError.ReadToEnd();
            if (p != null)
            {
                p.Close();
            }
            return output;
        }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值