Tag: ssh

如何在C#中的SSH服务器上运行命令?

我需要使用C#代码执行此操作: 在后台打开putty.exe(这就像一个cmd窗口) 使用其IP地址登录远程主机 输入用户名和密码 一个接一个地执行几个命令。 运行另一个命令,获取响应,告诉我在成功执行之前运行的命令 所以我试着这样做: ProcessStartInfo proc = new ProcessStartInfo() { FileName = @”C:\putty.exe”, UseShellExecute = true, //I think I need to use shell execute ? RedirectStandardInput = false, RedirectStandardOutput = false, Arguments = string.Format(“-ssh {0}@{1} 22 -pw {2}”, userName, hostIP, password) … //How do I send commands to be executed here ? […]

什么可能导致System.TypeLoadException?

我正在使用C#开发VS2008,这是一款适用于霍尼韦尔Dolphin 6100的应用程序,这是一款带有条形码扫描仪的移动计算机,它使用Windows CE 5.0,如操作系统。 我想添加一个function,可以将文件从本地设备发送到远程服务器。 我找到了可以保证这一点的图书馆“ Tamir.SharpSSH ”。 我在控制台应用程序和普通的Windows窗体应用程序上测试了代码,它运行得很好。 但是当我尝试在winCE设备上使用相同的代码时,我得到一个TypeLoadException并且我有错误消息: 无法从程序集’Tamir.SharpSSH加载’Tamir.SharpSsh.SshTransferProtocolBase’类型, Version = 1.1.1.13,Culture = neutral,PublicKeyToken = null’。 我使用的代码如下所示: SshTransferProtocolBase sshCp = new Scp(Tools.GlobalVarMeth.hostName, Tools.GlobalVarMeth.serverUserName); sshCp.Password = Tools.GlobalVarMeth.serverUserpassword; sshCp.Connect(); string localFile = Tools.GlobalVarMeth.applicationPath + “/” + fileName + “.csv”; string remoteFile = Tools.GlobalVarMeth.serverRemoteFilePath + “/” + fileName + “.csv”; sshCp.Put(localFile, remoteFile); sshCp.Close(); 有谁对此有任何想法? 我真的很感激!!!