Skip to content

Instantly share code, notes, and snippets.

@mumoshu
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mumoshu/e763fd5ce9a6159eabe5 to your computer and use it in GitHub Desktop.
Save mumoshu/e763fd5ce9a6159eabe5 to your computer and use it in GitHub Desktop.

以下のような感じで実装できるかも。

# ServerからClientへのKeepAliveに対する応答
connection.on_global_request("keep-alive@openssh.com") do |data, want_reply|
  puts "data: #{data.inspect}"
  puts "want_reply: #{want_reploy}"
end

# ClientからServerへのKeepAlive要求
new_connection.send_global_request("keep-alive@openssh.com")

ClientAliveIntervalが設定されているサーバへのSSH接続時のログ。 KeepAliveのため、サーバが「channel_request: 1 keepalive@openssh.com true」というリクエストをデータ送受信が止まっているチャンネルに送ってきている。 Net::SSHがこれに返答すれば、接続は切られない。

しかし、Net::SSHがそれに返答しない、というか、リクエストがずっとキューイングされたままになっていて、Net::SSHが気づいたときには既にKeepAlive失敗で接続が切られている。(「ignoring request :do_request for non-existent (closed?) channel; probably ssh server bug」のところ) そのため、最終的に「connection closed by remote host (Net::SSH::Disconnect)」でエラー終了している。

opening connection.
D, [2014-05-14T13:04:13.843683 #12085] DEBUG -- net.ssh.transport.session[3ff74e6bbe14]: establishing connection to localhost:49154
D, [2014-05-14T13:04:13.849980 #12085] DEBUG -- net.ssh.transport.session[3ff74e6bbe14]: connection established
I, [2014-05-14T13:04:13.850105 #12085]  INFO -- net.ssh.transport.server_version[3ff74e627214]: negotiating protocol version
D, [2014-05-14T13:04:13.857426 #12085] DEBUG -- net.ssh.transport.server_version[3ff74e627214]: remote is `SSH-2.0-OpenSSH_5.3'
D, [2014-05-14T13:04:13.857466 #12085] DEBUG -- net.ssh.transport.server_version[3ff74e627214]: local is `SSH-2.0-Ruby/Net::SSH_2.9.0 x86_64-darwin13.1.0'
D, [2014-05-14T13:04:13.870793 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 128 bytes
D, [2014-05-14T13:04:13.872051 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 128 bytes
D, [2014-05-14T13:04:13.873298 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 128 bytes
D, [2014-05-14T13:04:13.874575 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 128 bytes
D, [2014-05-14T13:04:13.875768 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 128 bytes
D, [2014-05-14T13:04:13.876894 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 128 bytes
D, [2014-05-14T13:04:13.877945 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 72 bytes
D, [2014-05-14T13:04:13.878018 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: received packet nr 0 type 20 len 836
I, [2014-05-14T13:04:13.878081 #12085]  INFO -- net.ssh.transport.algorithms[3ff74e606b2c]: got KEXINIT from server
I, [2014-05-14T13:04:13.878168 #12085]  INFO -- net.ssh.transport.algorithms[3ff74e606b2c]: sending KEXINIT
D, [2014-05-14T13:04:13.878284 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 0 type 20 len 2020
D, [2014-05-14T13:04:13.878337 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: sent 2024 bytes
I, [2014-05-14T13:04:13.878359 #12085]  INFO -- net.ssh.transport.algorithms[3ff74e606b2c]: negotiating algorithms
D, [2014-05-14T13:04:13.878460 #12085] DEBUG -- net.ssh.transport.algorithms[3ff74e606b2c]: 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:
D, [2014-05-14T13:04:13.879514 #12085] DEBUG -- net.ssh.transport.algorithms[3ff74e606b2c]: exchanging keys
D, [2014-05-14T13:04:13.880064 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 1 type 34 len 20
D, [2014-05-14T13:04:13.880133 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: sent 24 bytes
D, [2014-05-14T13:04:13.894087 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 128 bytes
D, [2014-05-14T13:04:13.895362 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 24 bytes
D, [2014-05-14T13:04:13.895447 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: received packet nr 1 type 31 len 148
D, [2014-05-14T13:04:13.897197 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 2 type 32 len 140
D, [2014-05-14T13:04:13.897251 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: sent 144 bytes
D, [2014-05-14T13:04:13.900581 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 128 bytes
D, [2014-05-14T13:04:13.901664 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 128 bytes
D, [2014-05-14T13:04:13.902763 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 128 bytes
D, [2014-05-14T13:04:13.903778 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 128 bytes
D, [2014-05-14T13:04:13.904874 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 128 bytes
D, [2014-05-14T13:04:13.905988 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 80 bytes
D, [2014-05-14T13:04:13.906053 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: received packet nr 2 type 33 len 700
D, [2014-05-14T13:04:13.907050 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 3 type 21 len 20
D, [2014-05-14T13:04:13.907099 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: sent 24 bytes
D, [2014-05-14T13:04:13.907142 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: received packet nr 3 type 21 len 12
D, [2014-05-14T13:04:13.907332 #12085] DEBUG -- net.ssh.authentication.session[3ff74e57a7f8]: beginning authentication of `kitchen'
D, [2014-05-14T13:04:13.907417 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 4 type 5 len 28
D, [2014-05-14T13:04:13.907450 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: sent 52 bytes
D, [2014-05-14T13:04:13.909131 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 52 bytes
D, [2014-05-14T13:04:13.909231 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: received packet nr 4 type 6 len 28
D, [2014-05-14T13:04:13.909316 #12085] DEBUG -- net.ssh.authentication.session[3ff74e57a7f8]: trying none
D, [2014-05-14T13:04:13.909419 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 5 type 50 len 44
D, [2014-05-14T13:04:13.909466 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: sent 68 bytes
D, [2014-05-14T13:04:13.911558 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 84 bytes
D, [2014-05-14T13:04:13.911636 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: received packet nr 5 type 51 len 60
D, [2014-05-14T13:04:13.911687 #12085] DEBUG -- net.ssh.authentication.session[3ff74e57a7f8]: allowed methods: publickey,gssapi-keyex,gssapi-with-mic,password
D, [2014-05-14T13:04:13.911721 #12085] DEBUG -- net.ssh.authentication.methods.none[3ff74e514138]: none failed
D, [2014-05-14T13:04:13.911777 #12085] DEBUG -- net.ssh.authentication.session[3ff74e57a7f8]: trying publickey
D, [2014-05-14T13:04:13.912007 #12085] DEBUG -- net.ssh.authentication.agent[3ff74e54263c]: connecting to ssh-agent
D, [2014-05-14T13:04:13.912101 #12085] DEBUG -- net.ssh.authentication.agent[3ff74e54263c]: sending agent request 1 len 51
D, [2014-05-14T13:04:13.912182 #12085] DEBUG -- net.ssh.authentication.agent[3ff74e54263c]: received agent packet 2 len 5
D, [2014-05-14T13:04:13.912218 #12085] DEBUG -- net.ssh.authentication.agent[3ff74e54263c]: sending agent request 11 len 0
D, [2014-05-14T13:04:13.912302 #12085] DEBUG -- net.ssh.authentication.agent[3ff74e54263c]: received agent packet 12 len 318
D, [2014-05-14T13:04:13.912527 #12085] DEBUG -- net.ssh.authentication.methods.publickey[3ff74e517270]: trying publickey (4c:df:c8:20:bd:47:16:43:d5:10:a4:5d:6b:01:e7:16)
D, [2014-05-14T13:04:13.912630 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 6 type 50 len 348
D, [2014-05-14T13:04:13.912672 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: sent 372 bytes
D, [2014-05-14T13:04:13.916242 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 128 bytes
D, [2014-05-14T13:04:13.917676 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 128 bytes
D, [2014-05-14T13:04:13.918984 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 68 bytes
D, [2014-05-14T13:04:13.919113 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: received packet nr 6 type 60 len 300
D, [2014-05-14T13:04:13.919247 #12085] DEBUG -- net.ssh.authentication.agent[3ff74e54263c]: sending agent request 13 len 653
D, [2014-05-14T13:04:13.926247 #12085] DEBUG -- net.ssh.authentication.agent[3ff74e54263c]: received agent packet 14 len 276
D, [2014-05-14T13:04:13.926362 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 7 type 50 len 620
D, [2014-05-14T13:04:13.926407 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: sent 644 bytes
D, [2014-05-14T13:04:13.933367 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 36 bytes
D, [2014-05-14T13:04:13.933474 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: received packet nr 7 type 52 len 12
D, [2014-05-14T13:04:13.933533 #12085] DEBUG -- net.ssh.authentication.methods.publickey[3ff74e517270]: publickey succeeded (4c:df:c8:20:bd:47:16:43:d5:10:a4:5d:6b:01:e7:16)
connection established, run uptime.
D, [2014-05-14T13:04:13.933779 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 8 type 90 len 44
D, [2014-05-14T13:04:13.933888 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: sent 68 bytes
D, [2014-05-14T13:04:13.957642 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 52 bytes
D, [2014-05-14T13:04:13.957808 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: received packet nr 8 type 91 len 28
I, [2014-05-14T13:04:13.957896 #12085]  INFO -- net.ssh.connection.session[3ff74e53b6ac]: channel_open_confirmation: 0 0 0 32768
I, [2014-05-14T13:04:13.958014 #12085]  INFO -- net.ssh.connection.channel[3ff74e53b530]: sending channel request "env"
D, [2014-05-14T13:04:13.958099 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 9 type 98 len 44
I, [2014-05-14T13:04:13.958176 #12085]  INFO -- net.ssh.connection.channel[3ff74e53b530]: sending channel request "exec"
D, [2014-05-14T13:04:13.958243 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 10 type 98 len 44
D, [2014-05-14T13:04:13.958323 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: sent 136 bytes
D, [2014-05-14T13:04:13.971210 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 88 bytes
D, [2014-05-14T13:04:13.971341 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: received packet nr 9 type 93 len 28
I, [2014-05-14T13:04:13.971411 #12085]  INFO -- net.ssh.connection.session[3ff74e53b6ac]: channel_window_adjust: 0 +2097152
D, [2014-05-14T13:04:13.971506 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: received packet nr 10 type 99 len 12
I, [2014-05-14T13:04:13.971566 #12085]  INFO -- net.ssh.connection.session[3ff74e53b6ac]: channel_success: 0
D, [2014-05-14T13:04:14.024715 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 128 bytes
D, [2014-05-14T13:04:14.024862 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: received packet nr 11 type 98 len 44
I, [2014-05-14T13:04:14.024923 #12085]  INFO -- net.ssh.connection.session[3ff74e53b6ac]: channel_request: 0 exit-status false
D, [2014-05-14T13:04:14.026203 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 112 bytes
D, [2014-05-14T13:04:14.026281 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: received packet nr 12 type 94 len 76
I, [2014-05-14T13:04:14.026322 #12085]  INFO -- net.ssh.connection.session[3ff74e53b6ac]: channel_data: 0 62b
D, [2014-05-14T13:04:14.026374 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: received packet nr 13 type 96 len 12
I, [2014-05-14T13:04:14.026399 #12085]  INFO -- net.ssh.connection.session[3ff74e53b6ac]: channel_eof: 0
D, [2014-05-14T13:04:14.026438 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: received packet nr 14 type 97 len 12
I, [2014-05-14T13:04:14.026465 #12085]  INFO -- net.ssh.connection.session[3ff74e53b6ac]: channel_close: 0
D, [2014-05-14T13:04:14.026522 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 11 type 97 len 28
 04:04:12 up  1:53,  0 users,  load average: 0.00, 0.01, 0.05
running uname -a
D, [2014-05-14T13:04:14.026602 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 12 type 90 len 44
D, [2014-05-14T13:04:14.026671 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: sent 120 bytes
D, [2014-05-14T13:04:14.028939 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 52 bytes
D, [2014-05-14T13:04:14.029080 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: received packet nr 15 type 91 len 28
I, [2014-05-14T13:04:14.029158 #12085]  INFO -- net.ssh.connection.session[3ff74e53b6ac]: channel_open_confirmation: 1 1 0 32768
I, [2014-05-14T13:04:14.029303 #12085]  INFO -- net.ssh.connection.channel[3ff74e56c298]: sending channel request "env"
D, [2014-05-14T13:04:14.029413 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 13 type 98 len 44
I, [2014-05-14T13:04:14.029529 #12085]  INFO -- net.ssh.connection.channel[3ff74e56c298]: sending channel request "exec"
D, [2014-05-14T13:04:14.029629 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 14 type 98 len 44
D, [2014-05-14T13:04:14.029730 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: sent 136 bytes
D, [2014-05-14T13:04:14.051485 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 88 bytes
D, [2014-05-14T13:04:14.051669 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: received packet nr 16 type 93 len 28
I, [2014-05-14T13:04:14.051754 #12085]  INFO -- net.ssh.connection.session[3ff74e53b6ac]: channel_window_adjust: 1 +2097152
D, [2014-05-14T13:04:14.051858 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: received packet nr 17 type 99 len 12
I, [2014-05-14T13:04:14.051907 #12085]  INFO -- net.ssh.connection.session[3ff74e53b6ac]: channel_success: 1
D, [2014-05-14T13:04:14.104305 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 128 bytes
D, [2014-05-14T13:04:14.105899 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 128 bytes
D, [2014-05-14T13:04:14.106023 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: received packet nr 18 type 94 len 124
I, [2014-05-14T13:04:14.106101 #12085]  INFO -- net.ssh.connection.session[3ff74e53b6ac]: channel_data: 1 103b
D, [2014-05-14T13:04:14.106215 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: received packet nr 19 type 98 len 44
I, [2014-05-14T13:04:14.106267 #12085]  INFO -- net.ssh.connection.session[3ff74e53b6ac]: channel_request: 1 exit-status false
D, [2014-05-14T13:04:14.106375 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: received packet nr 20 type 96 len 12
I, [2014-05-14T13:04:14.106429 #12085]  INFO -- net.ssh.connection.session[3ff74e53b6ac]: channel_eof: 1
D, [2014-05-14T13:04:14.107394 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 32 bytes
D, [2014-05-14T13:04:14.107462 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: received packet nr 21 type 97 len 12
I, [2014-05-14T13:04:14.107492 #12085]  INFO -- net.ssh.connection.session[3ff74e53b6ac]: channel_close: 1
D, [2014-05-14T13:04:14.107549 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 15 type 97 len 28
Linux 419a2689e628 3.14.1-tinycore64 #1 SMP Thu May 8 02:04:41 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
sleeping for 300 seconds.
I, [2014-05-14T13:04:44.108109 #12085]  INFO -- net.ssh.connection.session[3ff74e53b6ac]: sending global request keep-alive@openssh.com
D, [2014-05-14T13:04:44.108424 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 16 type 80 len 44
30
I, [2014-05-14T13:05:14.109681 #12085]  INFO -- net.ssh.connection.session[3ff74e53b6ac]: sending global request keep-alive@openssh.com
D, [2014-05-14T13:05:14.109864 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 17 type 80 len 44
60
I, [2014-05-14T13:05:44.110517 #12085]  INFO -- net.ssh.connection.session[3ff74e53b6ac]: sending global request keep-alive@openssh.com
D, [2014-05-14T13:05:44.110667 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 18 type 80 len 44
90
I, [2014-05-14T13:06:14.111881 #12085]  INFO -- net.ssh.connection.session[3ff74e53b6ac]: sending global request keep-alive@openssh.com
D, [2014-05-14T13:06:14.112056 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 19 type 80 len 44
120
I, [2014-05-14T13:06:44.113073 #12085]  INFO -- net.ssh.connection.session[3ff74e53b6ac]: sending global request keep-alive@openssh.com
D, [2014-05-14T13:06:44.113259 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 20 type 80 len 44
150
I, [2014-05-14T13:07:14.113696 #12085]  INFO -- net.ssh.connection.session[3ff74e53b6ac]: sending global request keep-alive@openssh.com
D, [2014-05-14T13:07:14.113911 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 21 type 80 len 44
180
I, [2014-05-14T13:07:44.114876 #12085]  INFO -- net.ssh.connection.session[3ff74e53b6ac]: sending global request keep-alive@openssh.com
D, [2014-05-14T13:07:44.115060 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 22 type 80 len 44
210
I, [2014-05-14T13:08:14.116140 #12085]  INFO -- net.ssh.connection.session[3ff74e53b6ac]: sending global request keep-alive@openssh.com
D, [2014-05-14T13:08:14.116311 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 23 type 80 len 44
240
I, [2014-05-14T13:08:44.117525 #12085]  INFO -- net.ssh.connection.session[3ff74e53b6ac]: sending global request keep-alive@openssh.com
D, [2014-05-14T13:08:44.117708 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 24 type 80 len 44
270
I, [2014-05-14T13:09:14.118462 #12085]  INFO -- net.ssh.connection.session[3ff74e53b6ac]: sending global request keep-alive@openssh.com
D, [2014-05-14T13:09:14.118703 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 25 type 80 len 44
300
running uptime.
D, [2014-05-14T13:09:14.118868 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: queueing packet nr 26 type 90 len 44
D, [2014-05-14T13:09:14.118966 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 340 bytes
D, [2014-05-14T13:09:14.119051 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: received packet nr 22 type 98 len 44
I, [2014-05-14T13:09:14.119126 #12085]  INFO -- net.ssh.connection.session[3ff74e53b6ac]: channel_request: 1 keepalive@openssh.com true
W, [2014-05-14T13:09:14.119171 #12085]  WARN -- net.ssh.connection.session[3ff74e53b6ac]: ignoring request :do_request for non-existent (closed?) channel; probably ssh server bug
D, [2014-05-14T13:09:14.119215 #12085] DEBUG -- tcpsocket[3ff74e6ae980]: read 0 bytes
/Users/mumoshu/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/net-ssh-2.9.0/lib/net/ssh/transport/packet_stream.rb:87:in `next_packet': connection closed by remote host (Net::SSH::Disconnect)
	from /Users/mumoshu/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/net-ssh-2.9.0/lib/net/ssh/transport/session.rb:178:in `block in poll_message'
	from /Users/mumoshu/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/net-ssh-2.9.0/lib/net/ssh/transport/session.rb:173:in `loop'
	from /Users/mumoshu/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/net-ssh-2.9.0/lib/net/ssh/transport/session.rb:173:in `poll_message'
	from /Users/mumoshu/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/net-ssh-2.9.0/lib/net/ssh/connection/session.rb:460:in `dispatch_incoming_packets'
	from /Users/mumoshu/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/net-ssh-2.9.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
	from /Users/mumoshu/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/net-ssh-2.9.0/lib/net/ssh/connection/session.rb:205:in `process'
	from /Users/mumoshu/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/net-ssh-2.9.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
	from /Users/mumoshu/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/net-ssh-2.9.0/lib/net/ssh/connection/session.rb:169:in `loop'
	from /Users/mumoshu/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/net-ssh-2.9.0/lib/net/ssh/connection/session.rb:169:in `loop'
	from /Users/mumoshu/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/net-ssh-2.9.0/lib/net/ssh/connection/channel.rb:269:in `wait'
	from /Users/mumoshu/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/net-ssh-2.9.0/lib/net/ssh/connection/session.rb:364:in `exec!'
	from test.rb:28:in `<main>'
#!/usr/bin/env ruby
require 'net/ssh'
# NOTE - did not successfully fix the issue.
#Net::SSH::Transport::Algorithms::ALGORITHMS[:encryption] = %w(aes128-cbc 3des-cbc blowfish-#cbc cast128-cbc
# aes192-cbc aes256-cbc none arcfour128 arcfour256 arcfour
# aes128-ctr aes192-ctr aes256-ctr cast128-ctr blowfish-ctr 3des-ctr)
puts "opening connection.\n"
new_connection = Net::SSH.start('localhost', 'kitchen', {:keys => ['/Users/mumoshu/.ssh/id_rsa'], :keepalive => true, :keepalive_interval => 60, :timeout => 60, :port => 49156, :verbose => :debug})
puts "connection established, run uptime.\n"
puts new_connection.exec!('uptime')
puts "running uname -a\n"
puts new_connection.exec!('uname -a')
puts "sleeping for 300 seconds.\n"
(1..10).each do |iterator|
sleep_seconds = iterator * 30
sleep 30
puts "#{sleep_seconds}\n"
end
puts "running uptime.\n"
puts new_connection.exec!('uptime')
puts "running uname -a\n"
puts new_connection.exec!('uname -a')
puts "closing connection.\n"
new_connection.close
puts "done.\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment