Class | Net::SSH::Session |
In: |
lib/net/ssh/session.rb
|
Parent: | Object |
Encapsulates a single session (connection) to a server via SSH.
host | [R] | The name of the host that this session is connected to. |
options | [R] | The hash of options that were used to establish this session. |
registry | [R] | The dependency-injection registry used by this session. |
Create a new SSH session. This method polymorphically accepts a variable number of parameters, as follows:
Any scenario above that omits the username assumes that the USER environment variable is set to the user’s name. Any scenario above that omits the password assumes that the user will log in without a password (ie, using a public key). Any scenario above that omits the port number assumes a port number of 22 (the default for SSH).
Any of the above scenarios may also accept a Hash as the last parameter, specifying a list of additional options to be used to initialize the session. (See Net::SSH::Session.add_options).
Alternatively, named parameters may be used, in which case the first parameter is positional and is always the host to connect to, following which you may specify any of the following named parameters (as symbols):
Any additional parameters are treated as options that configure how the connection behaves.
Allowed options are:
Also, any options recognized by Net::SSH::Transport::Session may be given, and will be passed through to initialize the transport session.
If a block is given to this method, then it is called with the new session object. The session object is then closed when the block terminates. If a block is not given, then the session object is returned (and must be closed explicitly).
Enters the main communication loop. This processes events occuring over the channel. If a block is given, the loop will continue for as long as the block returns true. Otherwise, the loop continues until there are no more open channels. (See Net::SSH::Connection::Driver#loop).
Provides convenient access to services that have been registered with the session, such as "process" and "forward".
Usage:
session.forward.local(...)
Opens a new communication channel over the current connection. This returns immediately. The block will be invoked when then the channel has been opened. (See Net::SSH::Connection::Driver#open_channel).