Login  
Search All Forums
Dart Home | PowerTCP SFTP & SSH for .NET | Custom Development Reply | PowerTCP SFTP & SSH for .NET Topics | Forums   
AuthorForum: PowerTCP SFTP & SSH for .NET
Topic: Connect method hangs
ImACoder

From: Berkeley, MO USA
Posts: 6
Member Since: 03/16/12
posted March 16, 2012 2:19 PM

I am new to this technology and I have reviewed the documentation and the examples. I have placed a SFTP component on my form and I set AcceptAllHostKeys to false and set up all of the events. I then attempted to run the connection method. 

MySFTP.Connect("MyHostName", 5000)
MySFTP.Connect("100.100.100.100", 5000)

If the hostname is not known then it returns with an exception as I would expect. If I use the IP Address then "connect" hangs and becomes unresponsive and then I have to kill the process. Is there anything I'm missing?

Is there anything that explains how to use SFTP where the host has a key and does not expect a user id and password? Thanks for any help.
Nick B (Admin)

From: Utica, NY USA
Posts: 619
Member Since: 05/25/10

Extra Support Options
Custom Application Development

posted March 16, 2012 3:44 PM

Hello,

I tested setting AcceptAllHostKeys to false, and tried connecting to 100.100.100.100. The method consistently threw an exception after 20 seconds (default). The 5000 timeout is only for the key exchange. Specifying an unknown hostname will fail more quickly because the DNS server indicates that it doesn't find a record for the requested hostname, and therefore doesn't attempt to connect to an IP address.

I also tested this with the HostKey event hooked up, and it never fired. Please let me know if there are any other circumstances that I need to replicate in order to reproduce your issue.

Can you explain what you mean by "host has a key"? If you're asking how to login with only a PEM key, without a username, so far as we know that isn't possible by the protocol. If you have a server that supports this, please provide us with its details.
ImACoder

From: Berkeley, MO USA
Posts: 6
Member Since: 03/16/12
posted March 19, 2012 9:39 AM

Thank you for your response. I have been able to get the SFTP to throw an exception as you describe.

Again, I am very new to this so I am unsure of how this process runs. What I mean by "host has a key" is that the host has a public key for security. I am assuming that when I attempt to connect the host responds with the public key and the "Challenge" or "HostKey" event would fire. I'm not seeing this.

In fact I have to assume that I am hitting the host correctly because it is not timing out. But I am not seeing a response from the host either. The process just stops and I have to kill it.

I have ensured that the SynchronizingObject is set the form that has the SFTP instance.

I have wired up all the events SFTP exposes and nothing is firing. Am I missing something I need to do either before or after the "connect" method? 

A quick note: I have removed the "5000" millisecond timeout for the time being.

Thanks for any help, I'm under the gun to get this up quickly.
Nick B (Admin)

From: Utica, NY USA
Posts: 619
Member Since: 05/25/10

Extra Support Options
Custom Application Development

posted March 19, 2012 10:05 AM

Hello,

The host key is unrelated to the public/private keypair. It is used only to identify that the server is the server you're trying to connect to. The HostKey event is raised when the server sends a host key.

The challenge event is raised when performing Challenge/Response (keyboard-interactive) authentication. That event is only raised when using the Authenticate overload that takes a string array, and the server supports keyboard-interactive authentication.

If you need to use publickey authentication, use the Authenticate() overload that takes three strings.

Have you tried using our included SFTP client with your server? It can show you how to use publickey authentication, and can ensure that our component will connect and authenticate successfully against your server.

Only the HostKey event will fire on Connect, and only once the server has sent its host key.

Authenticate must be called after connecting to your server.
ImACoder

From: Berkeley, MO USA
Posts: 6
Member Since: 03/16/12
posted March 19, 2012 10:09 AM

Ok, I'll try what you suggest. I don't know if your client has also been installed on the server. I'll try your suggestions first.

Thank you very much for your help.
ImACoder

From: Berkeley, MO USA
Posts: 6
Member Since: 03/16/12
posted March 19, 2012 12:42 PM

I am checking to see if the SFTP client is installed on the host as you asked. I hope to know soon. But I am wondering if this is part of the SFTP client on the server of this is something different...

I have been able to connect (to a point) but now I get the exception '{"Invalid PEM structure, '-----BEGIN...' missing"}'. I used the PuttyGen utility to get the public key from the private key. But when I attempt the authenticate it immediately fails. The first line of the public key that was extracted is:
'---- BEGIN SSH2 PUBLIC KEY ----
Comment: "rsa-key-20120222"' 

I have the AllowAllHostKeys set to True currently. I even went so far as to modify the file directly. I am using It keeps sending the same error. Nothing I try seems to work. What might cause this kind of error?
ImACoder

From: Berkeley, MO USA
Posts: 6
Member Since: 03/16/12
posted March 19, 2012 12:57 PM

As a follow up I used the SshSamples.VB40 provided and used the PEM from our host's private key. I get the same '{"Invalid PEM structure, '-----BEGIN...' missing"}' error with it as well.

One other update, the host server is a UNIX platform. The team on that side said they have SFTP capability installed.
Nick B (Admin)

From: Utica, NY USA
Posts: 619
Member Since: 05/25/10

Extra Support Options
Custom Application Development

posted March 19, 2012 1:29 PM

Your key appears to not be in PEM format, but in SSH2 format, which we don't support. Please see the Authenticate(string, string, string) method in the help documentation for more information on generating a valid PEM file.

AllowAllHostKeys does not affect this (the host key is unrelated to public key authentication), but having it set to true will make getting things working easier at this point.
ImACoder

From: Berkeley, MO USA
Posts: 6
Member Since: 03/16/12
posted March 19, 2012 2:46 PM

Ok, that worked. Thanks so much for your help.
Reply | PowerTCP SFTP & SSH for .NET Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX