sharpssh

使用SharpSSH库实现的最简单的SSH控制台

余生长醉 提交于 2020-04-18 05:48:58
今天研究了下怎么用C#程序通过SSH连接远程的Linux系统,找到了SharpSSH,下载下来体验了一下: 1.下载SharpSSH SharpSSH的主页地址: http://www.tamirgal.com/blog/page/SharpSSH.aspx 这个页面中,在“Download”(下载)标题下,可以选择直接下载编译好的程序或是直接下载源码 下载程序:SharpSSH-1.1.1.13.bin.zip,SourceForge上的 下载地址 下载源码:SharpSSH-1.1.1.13.src.zip,SourceForge上的 下载地址 2.使用直接下载的二进制程序 直接下载的二进制程序,包括3个DLL文件和1个EXE文件,双击EXE文件就可以运行了 输入13,按下回车键,即可实现输入主机IP地址、用户名、登陆密码登陆一台Linux主机 我打开VMware虚拟机,启动一个RedHat,它的地址我配的是192.168.8.123,用户名为oracle,密码为1234 操作如下图: 进入主机后,输入exit命令关闭SSH连接 3.自己编写C#程序调用库文件实现这一功能 SharpSSH的源码注释和示例都做得很详细,我参考了里面的内容,写了下面这段代码,通过调用SharpSSH库实现了SharpSSH程序中的功能13: using System; using System

Sharpssh directory listing

感情迁移 提交于 2020-01-13 10:43:08
问题 I'm writing an application that allows me to up- and download files from a remote server. I'm using sftp as my transfer protocol and i need to list all files and directory's into a listview. I'm using sharpssh for sftp. Can somebody point me into the right direction? Thanks in forward, Bas van Ooyen 回答1: Sftp sftp = new Sftp(serverUri.Host, userName, password); sftp.Connect(); //the foldername cannot be empty, or the listing will not show ArrayList res = sftp.GetFileList("/foldername");

Sharpssh directory listing

两盒软妹~` 提交于 2020-01-13 10:42:38
问题 I'm writing an application that allows me to up- and download files from a remote server. I'm using sftp as my transfer protocol and i need to list all files and directory's into a listview. I'm using sharpssh for sftp. Can somebody point me into the right direction? Thanks in forward, Bas van Ooyen 回答1: Sftp sftp = new Sftp(serverUri.Host, userName, password); sftp.Connect(); //the foldername cannot be empty, or the listing will not show ArrayList res = sftp.GetFileList("/foldername");

Linux Command Doesn't work from .NET execution when using SharpSSH library

倾然丶 夕夏残阳落幕 提交于 2020-01-03 05:07:20
问题 I'm trying to run a very simple command in Linux via .NET using the SharpSsh .NET library. The code doesn't throw any exceptions, and it's still not working. When I run the sudo php /www/data/{directory}/scripts/create_file.php command from the terminal it creates the file. And when I run the sudo php /www/data/{directory}/scripts/delete_file.php command from the terminal, it deletes the file. When calling this code from .NET, I don't see the file being created/deleted. See this answer for

Veryfing fingerprints using SharpSSH while connecting to SFTP Server

自古美人都是妖i 提交于 2019-12-25 03:14:32
问题 I am using Tamir.SharpSSH to make SFTP connections in my .NET code. I have servers' host, port, username, password and servers' fingerprint. I am able to connect to the server without the fingerprint. Is there any way to match the fingerprint that I have with the servers' before making the connection? Following is my C# code for the connection: string _ftpURL = "ftp.com"; //Host URL or address of the SFTP server string _UserName = "Login_Id"; //User Name of the SFTP server string _Password =

Download file based on date modified from SFTP

蹲街弑〆低调 提交于 2019-12-18 18:03:21
问题 Is there a way to get the files from SFTP server that should be based on modified date using Tamir.SharpSsh? Currently I am downloading files by file name but my requirement is by Date Modified. var sftp = new Sftp(Host, UserName, Password); sftp.Connect(); sftp.Get(sourcePath+"/*.*." + name + "*", destinationPath); 回答1: SharpSsh does not allow that. It's a dead project, do not use it. Anyway, I took a look at the code to assess how difficult it would be add possibility to retrieve file

SFTP SSH.NET DLL instead of SharpSSH

青春壹個敷衍的年華 提交于 2019-12-18 07:24:48
问题 I was seeking for a free DLL for .net to handle SFTP connections. I found out this project SharpSSH, but it lacks of documentation. I spent a lot of time to figure how the dll works. I created a test project and I started to test different functions. Some functions are working such as deleting files. I have a problem with putfile() function and getfile(). Here an example : Dim ssh As SFTPUtil ssh = New SFTPUtil("MY SERVER", "MY USER", "MY PW") ssh.GetFile("/home/sftptest/test111.xml", "C:\

SharpSSH - SSHExec, run command, and wait 5 seconds for data!

你说的曾经没有我的故事 提交于 2019-12-13 02:48:56
问题 I have this code: using System; using System.Text; using Tamir.SharpSsh; using System.IO; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { SshExec exec = new SshExec("192.168.0.1", "admin", "haha"); exec.Connect(); string output = exec.RunCommand("interface wireless scan wlan1 duration=5"); Console.WriteLine(output); exec.Close(); } } } The command will execute! I can see that, but! It immediately prints data. Or actually, it does'nt print the data from the

how to use SharpSSH for Executing linux commands which prompts for additonal input?

徘徊边缘 提交于 2019-12-12 10:12:48
问题 Ok heres what I'm trying to do I have to setup an SSH session to a linux machine and issue a command like "ls" or cp. heres the snippet SshStream ssh = new SshStream ("myhost","root","pass"); ssh.Prompt ="#"; ssh.RemoveTerminalEmulationCharacters = true; byte[] byt = System.Text.Encoding.ASCII.GetBytes("rm vivek"); Array.Resize (ref byt,byt.Length +3 ); byt[byt.Length-1]=(byte)'\r'; byt[byt.Length - 2] = (byte)'y'; byt[byt.Length - 3] = (byte)'\r'; ssh.Write(byt); Console.WriteLine(ssh

Upload Download files from FTP site using SFTP

 ̄綄美尐妖づ 提交于 2019-12-11 05:44:49
问题 I need to know a way to connect to a FTP site through SFTP. I am using SharpSSH and i am unable to find an example to do the program. For now, i have downloaded the SharpSSH .DLL files and added as references. Now i need to write the code where i could connect, and upload/download files from the FTP server. How can i do this ? Help. UPDATE Code : //ip of the local machine and the username and password along with the file to be uploaded via SFTP. FileUploadUsingSftp("http://Some-sftp-site.com"