SSH/SFTP Communications in C#

I'm looking to get started implementing a SFTP handler in my application (.net 2.0) and so far I'm just not finding what I'm looking for. Seems like all the SSH/SFTP code and libraries out there are for the Linux crowd.

Can anyone point me in the right direction Am I going to be making calls to a command-line SSH app, or is this something that's going to be doable with reasonable effort


Answer this question

SSH/SFTP Communications in C#

  • Rothariger

    I don't believe .NET supports ssh natively ... Mono does, but I think these were added specifically for linux.

    http://www.jscape.com/articles/sftp_using_csharp.html
    appears to be what you'd be looking for.  There are other commercial .NET packages for ssh as well.

    Josh

  • vinoth.net

    TAG wrote:

    You need to search for third-party one.

    For example for SSH you can try this OpenSource http://www.routrek.co.jp/en/product/varaterm/granados.html as well there are a lot of others commertial vendors.

    This product (Granados) is SSH only, not SFTP. Anyone wanting to implement SFTP should consider extending Granados. (1) A combined SSH/SFTP product is far more useful than either one alone because the user does not need to learn two totally different ways to interface into these related protocols. (2) A lot of the functionality (such as all the crypto) is already there and you can focus on producing the file transfer functionality.


  • David Kelsall

    Microsoft does not provide thouse in-box.

    You need to search for third-party one. 

    For example for  SSH you can try this OpenSource http://www.routrek.co.jp/en/product/varaterm/granados.html as well there are a lot of others commertial vendors.


  • Niko331

    Hi Tamir

    I'm wanting to transfer files over sftp in from an asp.net website to an sftp server. Will your classes adapt for this task ie. Running in a remote host envirmonment as opposed to a windows app environment

    Any advice much appreciated.

    Cheers.


  • Paul Seaton-Smith

    SSH is not SSL, and SFTP is not FTP over SSL.

  • kantan

    Hello Tamir,

    I am using your SharpSsh, but it doesn't work with commands for removing files. I tried to do it with SshExec and with SshShell by running a command "rm -f filename.wav", but didn't achieve to get a response. The command starts and never ends... Any idea

    Please answer as soon as possible.

    Regards,
    L.

    I also posted the same question on code project, but nobody answered...



  • tbiggins

    thanks TAG I hadn't seen that one before, I'll look into it.

  • moria

    Rebex SFTP for .NET / .NET CF will also do the job. The interface seems to be easy-to-learn - see following example taken from SFTP component tutorial page.

    // create client, connect and log in 
    Sftp client = new Sftp();
    client.Connect("sftp.example.org");
    client.Login("username", "password");

    // select the desired directory
    client.ChangeDirectory("path");

    // retrieve and display the list of files and directories
    SftpItemCollection list = client.GetList ();
    foreach (SftpItem item in list)
    {
    Console.Write(item.Modified.ToString("u"));
    Console.Write(item.Size.ToString().PadLeft(10,' '));
    Console.Write(" {0}", item.Name);
    Console.WriteLine();
    }
    Martin Vobr

  • rafidheen

    SSL/FTP is already supported in System.Net 2.0
    You can also use Sockets/NetworkStream
    and then compose an SSLStream on top of the NetworkSteam.
    That way you don't need to worry about the SSL implementation



  • Kim Greenlee

    Scott C. Reynolds wrote:
    I'm looking to get started implementing a SFTP handler in my application (.net 2.0) and so far I'm just not finding what I'm looking for. Seems like all the SSH/SFTP code and libraries out there are for the Linux crowd.

    Can anyone point me in the right direction Am I going to be making calls to a command-line SSH app, or is this something that's going to be doable with reasonable effort

    There's a number of SSH/SFTP solutions for .NET.

    You can check the comparison chart at http://www.eldos.com/sbb/sftpcompare.php . See the sample of how to use SFTP with VB.NET on http://www.eldos.com/sbb/sftp.net/sftp-net-vb-sample.php

    Sincerely yours,

    Eugene Mayevski


  • Captain Nimmo

    i tried with the Sharp SSH componet . it works to implementconnection with remote server but while upload/download files i am getting error like "unknown error"


  • Paul Johansen

    http://www.tamirgal.com/home/dev.aspx Item=sharpSsh

    Is another link to this project.  I just tested it and it works great for transfering SFTP files. 

  • Josh L

    Hi,

    Recently I ported some of the JSch java SSH lib to C#. I posted my code at the codeproject website: http://www.codeproject.com/useritems/sharpSsh.asp.
    The demo project contains an examples directory that also contains an SFPT implementation.

  • Mr_Amit_W

    Can you direct me to where in Mono ssh is supported natively I need ssh and maybe scp. I realize I could use one of the other solutions mentioned in this thread, but if it is possible to use Mono's libraries, that would be much more preferable.

    Thanks!

  • SSH/SFTP Communications in C#