Created
July 15, 2018 14:49
-
-
Save kingsleyh/5a5f7a58fa9ac980d90c00785d86f02e to your computer and use it in GitHub Desktop.
ssh2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "ssh2" | |
SSH2::Session.open("localhost", 22) do |session| | |
session.login("test", "password") | |
session.open_session do |ch| | |
ch.request_pty("vt100") | |
ch.shell | |
session.blocking = false | |
buf_space = uninitialized UInt8[1024] | |
buf = buf_space.to_slice | |
spawn do | |
ch.write(gets.to_slice) | |
end | |
spawn do | |
if ch.socket | |
len = ch.read(buf).to_i32 | |
print String.new buf[0, len] | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment