Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
20.2k views
in .NET FTP by (580 points)
I am not totally stupid, but....

I have an ASP.NET 1.1 application from which a client wants me to send them a file via SFTP... they have an SFTP Server their end.

I can't get my head round what I require - is edFTPNet enough? Or have I got to install some sort of SFTP Servver (or SSH Server) as well?

I don't need any UI in my application - it will simply create a file each day and then SFTP it across to the client.

Is there an "How to for dummies" anywhere? :)

Thanks...

22 Answers

0 votes
by (580 points)
Hi - well...

Setting
conn.LogLevel = LogLevel.All;
yields no errors that I can see ; indeed, setting
conn.LogLevel = LogLevel.Error;
yields a blank file...

BUT

The code jumps out of my try-catch block on the
conn.Connect()
line, and catching the error message reads:

Cannot access a disposed object named "System.Net.Sockets.Socket". Object name: "System.Net.Sockets.Socket".
NB this is the error message returned by the .NET application, - there is no error reported in the log file!

here's my code (VB) - I hope i'm not anything totally dumb...

Dim conn As EnterpriseDT.Net.Ftp.SecureFTPConnection = New EnterpriseDT.Net.Ftp.SecureFTPConnection
Try
conn.LogLevel = EnterpriseDT.Util.Debug.LogLevel.All
conn.LogFile = Server.MapPath("_edtlogerr.txt")
conn.ServerValidation = SecureFTPServerValidationType.None
conn.Protocol = FileTransferProtocol.SFTP
conn.ServerPort = 22
conn.PublicIPAddress = "My IP"
conn.ServerAddress = "Remote IP"
conn.License Owner = "" ' as per registry entry - space to cater for posting
conn.License Key = "" ' as per registry entry- space to cater for posting
conn.UserName = "username" ' as required by remote server
conn.Password = "password" ' as required by remote server
conn.Connect()
lblX.Text &= "Connected... "
conn.Close()
lblX.Text &= "OK!"
Catch ex As Exception
lblX.Text &= "; " & ex.Message
If conn.IsConnected Then conn.Close()
End Try
0 votes
by (162k points)
Could you post the log file? That will let us see how far it gets ...
0 votes
by (580 points)
OK - don't suppose it really matters but I have replace all occurrences of the remote IP with "Remote.IP", as it's my client's server...
thanks..

INFO [LicenseProperties] 15 Jan 2009 23:11:12.405 : Licence expiry date: 26/02/2009
INFO [LicenseProperties] 15 Jan 2009 23:11:12.405 : Trial license
DEBUG [FTPConnection] 15 Jan 2009 23:11:12.405 : Set LocalDirectory='c:\windows\system32\inetsrv'
INFO [LicenseProperties] 15 Jan 2009 23:11:12.405 : Licence expiry date: 26/02/2009
INFO [LicenseProperties] 15 Jan 2009 23:11:12.405 : Trial license
DEBUG [SSHFTPClient] 15 Jan 2009 23:11:12.405 : Setting up fallback kbi prompt based on supplied password
DEBUG [HostNameResolver] 15 Jan 2009 23:11:12.405 : Remote.IP resolved to Remote.IP
DEBUG [SSHFTPClient] 15 Jan 2009 23:11:12.405 : Connecting directly to SFTP server Remote.IP:22
DEBUG [SSHFTPClient] 15 Jan 2009 23:11:12.437 : Connected successfully to SFTP server Remote.IP:22
DEBUG [SSHConnection] 15 Jan 2009 23:11:12.437 : Beginning protocol negotiation
DEBUG [PlainSocket] 15 Jan 2009 23:11:12.499 : RepeatCallback received 20 bytes
DEBUG [ProtocolNegotiationHandler] 15 Jan 2009 23:11:12.499 : offset=0,length=20
DEBUG [ProtocolNegotiationHandler] 15 Jan 2009 23:11:12.499 : pos=19
INFO [ProtocolNegotiationHandler] 15 Jan 2009 23:11:12.499 : Server version = 'SSH-2.0-OpenSSH_4.7'
DEBUG [ProtocolNegotiationHandler] 15 Jan 2009 23:11:12.499 : Major string = '2'
DEBUG [ProtocolNegotiationHandler] 15 Jan 2009 23:11:12.499 : Minor string = '0'
DEBUG [ProtocolNegotiationHandler] 15 Jan 2009 23:11:12.499 : Version 2.0
DEBUG [ProtocolNegotiationHandler] 15 Jan 2009 23:11:12.499 : Protocol compatible
DEBUG [SSHConnection] 15 Jan 2009 23:11:12.499 : Server version=SSH-2.0-OpenSSH_4.7
DEBUG [SSH2Connection] 15 Jan 2009 23:11:12.499 : Timeout=120000
DEBUG [SSHConnection] 15 Jan 2009 23:11:12.499 : Sending client version=SSH-2.0-edtFTPnet/PRO-6.0.0.11
DEBUG [SSH2Connection] 15 Jan 2009 23:11:12.499 : Starting key exchange
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.499 : Sending SSH_MSG_KEXINIT
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.499 : Client hostkey algorithms=ssh-dss,ssh-rsa
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.499 : Client ciphers=aes128-cbc,aes192-cbc,aes256-cbc,blowfish-cbc,3des-cbc
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.499 : Client ciphers=aes128-cbc,aes192-cbc,aes256-cbc,blowfish-cbc,3des-cbc
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.499 : Client MACs=hmac-sha1,hmac-md5
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.499 : Client MACs=hmac-sha1,hmac-md5
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.499 : Client compression algorithms=none,zlib
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.499 : Client compression algorithms=none,zlib
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.499 : Sent SSH_MSG_KEXINIT
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.499 : Reading SSH_MSG_KEXINIT reply
DEBUG [SSH2Connection] 15 Jan 2009 23:11:12.499 : Waiting for packet
DEBUG [PlainSocket] 15 Jan 2009 23:11:12.530 : RepeatCallback received 784 bytes
DEBUG [SSH2PacketBuilder] 15 Jan 2009 23:11:12.530 : ConstructPacket: _cipher=null,len=780
DEBUG [SSH2PacketBuilder] 15 Jan 2009 23:11:12.530 : Writeoffset=784,Readoffset=784
DEBUG [SSH2Connection] 15 Jan 2009 23:11:12.530 : Packet arrived
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.530 : Processing SSH_MSG_KEXINIT reply
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.530 : Kex alg=diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.530 : Hostkey alg=ssh-rsa,ssh-dss
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.530 : Cipher CS=aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.530 : Cipher C->S= AES128
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.530 : Cipher SC=aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.530 : Cipher S->C= AES128
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.530 : MAC CS=hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.530 : MAC C->S= HMACSHA1
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.530 : MAC SC=hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.530 : MAC S->C= HMACSHA1
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.530 : Comp CS=none,zlib@openssh.com
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.530 : Comp C->S=None
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.530 : Comp SC=none,zlib@openssh.com
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.530 : Comp S->C=None
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.530 : Processed SSH_MSG_KEXINIT reply
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.530 : Sending SSH_MSG_KEXDH_INIT
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.530 : Sent SSH_MSG_KEXDH_INIT
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.530 : Reading SSH_MSG_KEXDH_INIT reply
DEBUG [SSH2Connection] 15 Jan 2009 23:11:12.530 : Waiting for packet
DEBUG [PlainSocket] 15 Jan 2009 23:11:12.593 : RepeatCallback received 656 bytes
DEBUG [SSH2PacketBuilder] 15 Jan 2009 23:11:12.593 : ConstructPacket: _cipher=null,len=636
DEBUG [SSH2PacketBuilder] 15 Jan 2009 23:11:12.593 : ConstructPacket: _cipher=null,len=12
DEBUG [SSH2Connection] 15 Jan 2009 23:11:12.593 : Packet arrived
DEBUG [SSH2PacketBuilder] 15 Jan 2009 23:11:12.593 : Writeoffset=656,Readoffset=656
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.593 : Processing SSH_MSG_KEXDH_INIT reply
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.624 : Processed SSH_MSG_KEXDH_INIT reply successfully
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.624 : Sending SSH_MSG_NEWKEYS
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.624 : Sent SSH_MSG_NEWKEYS
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.624 : Established ciphers
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.624 : Established MACs
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.624 : Reading SSH_MSG_NEWKEYS reply
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.624 : Processing SSH_MSG_NEWKEYS reply
DEBUG [KeyExchanger] 15 Jan 2009 23:11:12.624 : Processed SSH_MSG_NEWKEYS reply
DEBUG [SSH2Connection] 15 Jan 2009 23:11:12.624 : Key exchange complete
DEBUG [SSH2Connection] 15 Jan 2009 23:11:12.624 : Sent SSH_MSG_SERVICE_REQUEST 'ssh-userauth'
DEBUG [SSH2Connection] 15 Jan 2009 23:11:12.624 : Waiting for packet
DEBUG [PlainSocket] 15 Jan 2009 23:11:12.765 : RepeatCallback received 52 bytes
DEBUG [SSH2PacketBuilder] 15 Jan 2009 23:11:12.765 : Writeoffset=52,Readoffset=52
DEBUG [SSH2Connection] 15 Jan 2009 23:11:12.765 : Packet arrived
DEBUG [SSH2Connection] 15 Jan 2009 23:11:12.765 : Starting user authentication
DEBUG [SSH2Connection] 15 Jan 2009 23:11:12.765 : Password authentication
DEBUG [SSH2Connection] 15 Jan 2009 23:11:12.765 : Sent SSH_MSG_USERAUTH_REQUEST
DEBUG [SSH2Connection] 15 Jan 2009 23:11:12.765 : Waiting for packet
DEBUG [PlainSocket] 15 Jan 2009 23:11:12.812 : RepeatCallback received 36 bytes
DEBUG [SSH2PacketBuilder] 15 Jan 2009 23:11:12.812 : Writeoffset=36,Readoffset=36
DEBUG [SSH2Connection] 15 Jan 2009 23:11:12.812 : Packet arrived
DEBUG [SSH2Connection] 15 Jan 2009 23:11:12.812 : ProcessAuthenticationResponse:
0 votes
by (162k points)
Ok, authentication works fine. The server is terminating the connection when the SFTP subservice is started.

Now is a good time to try another SFTP client on this machine to ensure that you can connect ok.
0 votes
by (580 points)
try another SFTP client


Another client? Do you mean try to connect to another SFTP server? I don't know any, except.. I tried to connect to

conn.ServerAddress = "ftp.microsoft.com"
conn.UserName = "anonymous"
conn.Password = "edtFTPnetPRO"

as per the example in your documentation, but got this:
"A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond "

Here;s the log file:
INFO [LicenseProperties] 16 Jan 2009 00:44:16.562 : Licence expiry date: 26/02/2009
INFO [LicenseProperties] 16 Jan 2009 00:44:16.562 : Trial license
DEBUG [FTPConnection] 16 Jan 2009 00:44:16.562 : Set LocalDirectory='c:\windows\system32\inetsrv'
INFO [LicenseProperties] 16 Jan 2009 00:44:16.562 : Licence expiry date: 26/02/2009
INFO [LicenseProperties] 16 Jan 2009 00:44:16.562 : Trial license
DEBUG [SSHFTPClient] 16 Jan 2009 00:44:16.562 : Setting up fallback kbi prompt based on supplied password
DEBUG [HostNameResolver] 16 Jan 2009 00:44:16.577 : ftp.microsoft.com resolved to 207.46.236.102
DEBUG [SSHFTPClient] 16 Jan 2009 00:44:16.577 : Connecting directly to SFTP server 207.46.236.102:22
that's it...

Could the original error (to my client's sftp server) be due to Firewall settings on the remote server? They are supposed to have set it up to allow connections from my IP... but as authentication works fine, as you say, I presume their Firewall isn't the problem....

sigh...
0 votes
by (162k points)
No, a firewall is unlikely to be the problem.

By another SFTP client, I mean something like Filezilla.

You can download it from here.

http://www.enterprisedt.com/tools/LogZilla.zip

Unzip and install on the machine your app is connecting from

File -> SIte Manager -> New Site and enter details.

For "Servertype" select SFTP using SSH2 and enter your login details. Then hit Connect.
0 votes
by (580 points)
Oh dear.. can't connect with Filezilla either..
"Fatal: Unable to initialise on SFTP on server: could not connect"
This (my client's) is a Windows 2003 server. The remote is (I believe) a Unix system...
0 votes
by (162k points)
SFTP is a protocol layered on top of SSH.

So it looks like the SSH part is working fine. The problem now is the SFTP "subsystem" isn't working. This is normally just a configuration file on the server, so you'll need to talk to them about it.
0 votes
by (580 points)
By "them" you mean the remote server's admin? As opposed to my client's server's admin (local server for these purposes) as that's me! And (as you may have gathered) I know next to nothing about server admin!! I don't know howe I got landed with looking after it for them... well, thanks for you time and help - I'll hope to see a reply to this last question, then I'm off to bed (01:32 here in the UK...)
cheers...
0 votes
by (162k points)
Yes, you (or your client) will need to talk to the admin who looks after the remote server (the SFTP server you are trying to connect to).

Tell them that SFTP isn't enabled (at least not for the credentials you are using) - you can authenticate but the SFTP subsystem isn't starting.

Categories

...