2

I have an issue where if I'm trying to create a ssh connection to a specific host, the connection hangs without timing out. I have tried connecting to this host from the same machine from outside the rails console and it works so I'm assuming this shouldn't be anything related to routing/firewall. I can also confirm I have several other hosts with the exact same OS configuration in different places and they work.

This is the log when running Net::SSH.start in debug mode:

ssh = Net::SSH.start("1.2.3.4", "user", password: "password", verbose: :debug)
2014-02-27 13:17:43 +0100 [DEBUG] establishing connection to 1.2.3.4:22
2014-02-27 13:17:43 +0100 [DEBUG] connection established
2014-02-27 13:17:43 +0100 [INFO] negotiating protocol version
2014-02-27 13:17:43 +0100 [DEBUG] remote is `SSH-2.0-OpenSSH_4.3'
2014-02-27 13:17:43 +0100 [DEBUG] local is `SSH-2.0-Ruby/Net::SSH_2.6.8 i686-linux'
2014-02-27 13:17:43 +0100 [DEBUG] read 704 bytes
2014-02-27 13:17:43 +0100 [DEBUG] received packet nr 0 type 20 len 700
2014-02-27 13:17:43 +0100 [INFO] got KEXINIT from server
2014-02-27 13:17:43 +0100 [INFO] sending KEXINIT
2014-02-27 13:17:43 +0100 [DEBUG] queueing packet nr 0 type 20 len 1620
2014-02-27 13:17:43 +0100 [DEBUG] sent 1624 bytes
2014-02-27 13:17:43 +0100 [INFO] negotiating algorithms
2014-02-27 13:17:43 +0100 [DEBUG] negotiated:
* kex: diffie-hellman-group-exchange-sha1
* host_key: ssh-rsa
* encryption_server: aes128-cbc
* encryption_client: aes128-cbc
* hmac_client: hmac-sha1
* hmac_server: hmac-sha1
* compression_client: none
* compression_server: none
* language_client: 
* language_server: 
2014-02-27 13:17:43 +0100 [DEBUG] exchanging keys
2014-02-27 13:17:43 +0100 [DEBUG] queueing packet nr 1 type 34 len 20
2014-02-27 13:17:43 +0100 [DEBUG] sent 24 bytes

At this point the ssh connection just hangs and could stay like this for 15-30 minutes. Unfortunately I have no error message or anything so I'm really clueless about what the problem might be.

Some specs:

ruby-2.0.0-p0
rails (3.2.13)
net-ssh-2.8.0

The IP address in the log is not a real IP on purpose.

Any suggestion about what the problem could be? Or maybe some other log or place I could check out? I found a similar problem outside SO but it didn't get a solution so I'm trying to ask here...

7
  • and no block is evaliated? Commented Feb 27, 2014 at 12:38
  • @МалъСкрылевъ I'm not using a block. Just trying to get a ssh object: ssh = Net::SSH.start("1.2.3.4", "user", password: "password", verbose: :debug)
    – Oktav
    Commented Feb 27, 2014 at 12:40
  • so the process haven't reach that line? Commented Feb 27, 2014 at 12:43
  • That's the line that's attempting to open the connection. The connection is clearly halted because there should be more data exchange between client and server.
    – Oktav
    Commented Feb 27, 2014 at 12:47
  • [DEBUG] negotiated: isn't this line says about data exchange? Commented Feb 27, 2014 at 13:15

1 Answer 1

1

I solved by reducing maximum transmission unit (MTU). My environment was some specific case. I was trying ssh from VMware Virtual Machine to Openstack Instance. And openstack needed smaller packet to be connected by kitchen-openstack which is using fog, using NET::SSH. Not sure if this works for you, but have a try for these commands (assuming in Ubuntu):

  1. check your MTU

    sudo netstat -i

  2. You'll get some output like this, in the second column, you can check MTU:

    Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg

    eth0 1500 0 9658 0 0 0 308 0 0 0 BMRU

    lo 16436 0 12952 0 0 0 12952 0 0 0 LRU

  3. For network interface eth0, you can try to reduce MTU from 1500 to, for example 1400 like this:

    sudo ifconfig eth0 mtu 1400

  4. try net ssh

    ssh = Net::SSH.start("1.2.3.4", "user", password: "password", verbose: :debug)

1
  • Thanks for the tip! I'll give that a try and get back to you
    – Oktav
    Commented Sep 25, 2014 at 8:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.