0 votes
by (120 points)
edited

I try to connect using the hostname: sw.mehome.net, 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:")
    Console.WriteLine(response)

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

2 Answers

0 votes
by (148k points)
edited

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
by (160 points)
edited

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

...