Class | Net::SSH::Multi::Server |
In: |
lib/net/ssh/multi/server.rb
|
Parent: | Object |
Encapsulates the connection information for a single remote server, as well as the Net::SSH session corresponding to that information. You‘ll rarely need to instantiate one of these directly: instead, you should use Net::SSH::Multi::Session#use.
== | -> | eql? |
gateway | [R] | The Net::SSH::Gateway instance to use to establish the connection. Will be nil if the connection should be established without a gateway. |
host | [R] | The host name (or IP address) of the server to connect to. |
master | [R] | The Net::SSH::Multi::Session instance that manages this server instance. |
options | [R] | The Hash of additional options to pass to Net::SSH when connecting (including things like :password, and so forth). |
user | [R] | The user name to use when logging into the server. |
Creates a new Server instance with the given connection information. The master argument must be a reference to the Net::SSH::Multi::Session instance that will manage this server reference. The options hash must conform to the options described for Net::SSH::start, with two additions:
The host argument may include the username and port number, in which case those values take precedence over similar values given in the options:
server = Net::SSH::Multi::Server.new(session, 'user@host:1234') puts server.user #-> user puts server.port #-> 1234
Indicates (by default) that this server has just failed a connection attempt. If flag is false, this can be used to reset the failed flag so that a retry may be attempted.
Returns the Net::SSH session object for this server. If require_session is false and the session has not previously been created, this will return nil. If require_session is true, the session will be instantiated if it has not already been instantiated, via the gateway if one is given, or directly (via Net::SSH::start) otherwise.
if server.session.nil? puts "connecting..." server.session(true) end
Note that the sessions returned by this are "enhanced" slightly, to make them easier to deal with in a multi-session environment: they have a :server property automatically set on them, that refers to this object (the Server instance that spawned them).
assert_equal server, server.session[:server]