Hostname connection error.

0 votes
asked Jul 19, 2010 by Steffen (120 points)
edited Mar 30, 2011

I try to connect using the hostname:, and I get the error: "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."

I use this code:

 client.Connect(hostname, port)
    client.Login(username, password)

    ' run the 'uname' command to retrieve OS info 
    Dim systemName As String = client.RunCommand("uname -a")
    ' display the output 
    Console.WriteLine("OS info: {0}", systemName)

    ' create client, connect and log in 
    ' ... 

    ' start the 'df' command to retrieve disk usage info 
    Dim shell As Shell = client.StartCommand("df")

    ' read all response, effectively waiting for the command to end 
    Dim response As String = shell.ReadAll()

    ' display the output 
    Console.WriteLine("Disk usage info:")

I've declared hostname, password, username and port.. Please help.

2 Answers

0 votes
answered Jul 19, 2010 by Lukas Pokorny (126,870 points)
edited Jul 19, 2010

This is a network error and usually means that the target machine is not accessible. Possible causes:

  1. The target machine is offline or not connected to the network at the moment.
  2. No SSH server runs at the target machine.
  3. Access to the specified port was blocked by firewall policy at the target machine.
  4. Access to the specified port was blocked by firewall policy at your local machine.

Are you able to connect to the target machine using any third-party SSH client (such as PuTTY) from the same computer where you tried running your code?

0 votes
answered Oct 13, 2010 by lav (160 points)
edited Oct 13, 2010

Hi Lukas, I try all possible causes but i get same error how to solve this problem?