Net::ssh - Drop User into shell

Discussion in 'Ruby' started by rilindo foster, Nov 17, 2010.

  1. I am trying to write a wrapper script that logs a person into a remote
    system and then drop them in to the shell on that machine.

    So far, it seems I am able to get as far as the prompt on the remote
    system. Afterwards, though, I am unable to send any response to the
    terminal.

    Here is the code:

    Net::SSH.start(host, username) do |ssh|
    channel = ssh.open_channel do | ch|
    ch.request_pty:)term => "xterm") do |ch, success|
    if success
    ch.send_channel_request("shell") do | ch, success |
    raise "Error opening shell" unless success
    end
    end
    end
    channel.on_data do |ch, data|
    STDOUT.print data
    end
    channel.on_extended_data do | ch, type, data|
    STDERR.print "Error: #{data}"
    end
    end
    channel.wait

    I think I probably need to add something to release control of the
    wrapper script to the user and it is likely a method under
    net::ssh:connection:channel. I am not sure, though, which one it is or
    even know how to invoke properly.

    I also tried to ssh.prompt method, but apparently that is not
    available when I create a channel object. Either that or I am not
    doing it right?

    Any suggestions? Or should I just go with wrapping the ssh binary
    instead and not use Net:SSH?

    - Rilindo
    rilindo foster, Nov 17, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    8
    Views:
    258
    Woody Peterson
    Sep 12, 2008
  2. Une Bévue

    net-ssh and remote shell

    Une Bévue, Jul 27, 2008, in forum: Ruby
    Replies:
    7
    Views:
    129
    Une Bévue
    Jul 29, 2008
  3. Tench Johnson
    Replies:
    1
    Views:
    274
    Biff Tannen
    Apr 23, 2010
  4. salamond

    net/ssh in ruby. ssh.exec fails

    salamond, Feb 17, 2011, in forum: Ruby
    Replies:
    0
    Views:
    219
    salamond
    Feb 17, 2011
  5. Replies:
    0
    Views:
    78
Loading...

Share This Page