15

I have to download some files from a SFTP location.

I am using the SharpSsh libraries but I am unable to connect.

Below are my SFTP details :

<add key="FTPHost" value="xyz.csod.com" />
<add key="FTPDirectory" value="/Test" />
<add key="FTPUserName" value="abc" />
<add key="FTPPassword" value="pass" />
<add key="FTPPort" value="22" />

And below is piece of code of c# to connect with SFTP :

using Tamir.SharpSsh;
using Tamir.SharpSsh.jsch;
using Tamir.Streams;

public string DownloadFile()
{                       
        Sftp oSftp = new Sftp(host, userName, password);//
        oSftp.Connect(port);
}

But I am getting exception at Connect().Is -

Additional information:

System.Net.Sockets.SocketException (0x80004005): The requested name is valid, but no data of the requested type was found

System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6) at System.Net.Dns.GetHostByName(String hostName) at Tamir.SharpSsh.java.net.Socket..ctor(String host, Int32 port) at Tamir.SharpSsh.jsch.Util.createSocket(String host, Int32 port, Int32 timeout)"

I am working with C# console application.

Community
  • 1
  • 1
Pawan Agrawal
  • 263
  • 2
  • 4
  • 11
  • 1
    1) What is a real value of `host` variable? Is it the `xyz.csod.com`? Or something else. It's not clear from your question. 2) Can you connect to the SFTP server from the same machine using GUI SFTP client? 3) Use another SFTP library. SharpSsh is not maintained for years. – Martin Prikryl Apr 09 '15 at 07:00

2 Answers2

7

You can see that is something wrong with your DNS issue. As exception throwing is a related with Win socket.

See following link for different kind of exceptions and meaning of exception related to windows socket.

https://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx#WSANO_DATA

Also I try to ping that domain which you asked in question and It's saying request timeout. So there must be something wrong with DNS.

If you have IP Address of this then try with IP and See are you able to connect on it.

Also make sure that. You have properly setup SFTP there on the server where you are trying to connect.

Also try to connect to there some server with some FTP client like filezilla or any other. If you are able to connect then there is a problem of code otherwise it is something related setup of STFP

Hope this will help you.

Jalpesh Vadgama
  • 13,653
  • 19
  • 72
  • 94
1

I had this error recently, it was resolved with a follow-up note from our server personnel "a reverse lookup zone for that IP address subnet was added/made available".

yakov72
  • 21
  • 2