Skip to main content

SFTP and File Upload in SFTP using C# and Tamir. SShSharp

The right choice of SFTP Server for Windows OS Follow the following steps, 1. Download the server version from here . The application is here 2. Provide the Username, password and root path, i.e. the ftp destination. 3. The screen shot is given below for reference.
4. Now download the CoreFTP client from this link 5. The client settings will be as in this screen shot:
6. Now the code to upload files via SFTP will be as follows.
//ip of the local machine and the username and password along with the file to be uploaded via SFTP.
 FileUploadUsingSftp("172.24.120.87", "ftpserveruser", "123456", @"D:\", @"Web.config");

private static void FileUploadUsingSftp(string FtpAddress, string FtpUserName, string FtpPassword, string FilePath, string FileName)
        {
            Sftp sftp = null;
            try
            {
                // Create instance for Sftp to upload given files using given credentials
                sftp = new Sftp(FtpAddress, FtpUserName, FtpPassword);

                // Connect Sftp
                sftp.Connect();

                // Upload a file
                sftp.Put(FilePath + FileName);

                // Close the Sftp connection
                sftp.Close();
            }
            finally
            {
                if (sftp != null)
                {
                    sftp.Close();
                }
            }
        }

7. The dependent dll files are 
   a. DiffieHellman
   b. Org.Mentalis.Security
   c. Tamir.SharpSSH

8. Additional documentation for the CORE FTP can be found here 
These can be downloaded by googling for the Tamir.SharpSSH.

Comments

  1. for me it DOES'T WORK....tell me the error:

    'Tamir.SharpSsh.jsch.JSchException' in Tamir.SharpSSH.dll

    Ulteriori informazioni: System.Net.Sockets.SocketException (0x80004005): Host sconosciuto

    in System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6)

    in System.Net.Dns.GetHostByName(String hostName)

    in Tamir.SharpSsh.java.net.Socket..ctor(String host, Int32 port)

    in Tamir.SharpSsh.jsch.Util.createSocket(String host, Int32 port, Int32 timeout)




    e fatele funzionanti ste guide dio maiale

    ReplyDelete
  2. I like your blog, I read this blog please update more content on hacking,Nice post
    .NET Online Course Hyderabad

    ReplyDelete

Post a Comment