无法使用C#SSH.NET更改目录

weixin_38051760 weixin_38051760 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
当我使用SSH.NET库连接到服务器时,默认文件夹是/ mif / stud3 / 2014 / rira1874.当我执行 res = ssh.CreateCommand("cd existingFolder").Execute(); Console.WriteLine(res); 它仍然保留在默认连接文件夹中.这有什么不对? 完整代码: public void ConnectWithPassword(string username, string password, string domain, int port) { bool i = true; using (var ssh = new SshClient(CreatePasswordConnectionInfo(username, password, domain))) { try { ssh.Connect(); if (ssh.IsConnected) { while(i == true) { string res = Regex.Replace(ssh.CreateCommand("pwd").Execute(), @"\r\n?|\n", ""); Console.Write(res + ": "); res = ssh.CreateCommand(Console.ReadLine()).Execute(); Console.WriteLine(res); } } else { Console.WriteLine("Not connected"); } ssh.Disconnect(); } catch (Exception e) { Console.WriteLine("Exception caught: {0}", e); } } }
...全文
评论 1
收藏 已收藏
分享
返回顶部