Class: ZTK::SSH
- Inherits:
-
Base
- Object
- Base
- ZTK::SSH
- Includes:
- Bootstrap, Command, Console, Core, Download, Exec, File, Private, Upload
- Defined in:
- lib/ztk/ssh.rb,
lib/ztk/ssh/file.rb,
lib/ztk/ssh/core.rb,
lib/ztk/ssh/exec.rb,
lib/ztk/ssh/upload.rb,
lib/ztk/ssh/console.rb,
lib/ztk/ssh/private.rb,
lib/ztk/ssh/command.rb,
lib/ztk/ssh/download.rb,
lib/ztk/ssh/bootstrap.rb
Overview
SSH Multi-function Class
We can get a new instance of SSH like so:
ssh = ZTK::SSH.new
If we wanted to redirect STDOUT and STDERR to a StringIO we can do this:
std_combo = StringIO.new
ui = ZTK::UI.new(:stdout => std_combo, :stderr => std_combo)
ssh = ZTK::SSH.new(:ui => ui)
If you want to specify SSH options you can:
keys = File.(File.join(ENV['HOME'], '.ssh', 'id_rsa'))
ssh = ZTK::SSH.new(:host_name => '127.0.0.1', :user => ENV['USER'], :keys => keys)
= Configuration Examples:
To proxy through another host, for example SSH to 192.168.1.1 through 192.168.0.1:
ssh.config do |config|
config.user = ENV['USER']
config.host_name = '192.168.1.1'
config.proxy_user = ENV['USER']
config.proxy_host_name = '192.168.0.1'
end
Specify an identity file:
ssh.config do |config|
config.keys = File.(File.join(ENV['HOME'], '.ssh', 'id_rsa'))
config.proxy_keys = File.(File.join(ENV['HOME'], '.ssh', 'id_rsa'))
end
Specify a timeout:
ssh.config do |config|
config.timeout = 30
end
Specify a password:
ssh.config do |config|
config.password = 'p@$$w0rd'
end
Check host keys, the default is false (off):
ssh.config do |config|
config.host_key_verify = true
end
Defined Under Namespace
Modules: Bootstrap, Command, Console, Core, Download, Exec, File, Private, Upload
Constant Summary
- EXIT_SIGNALS =
Exit Signal Mappings
{ 1 => "SIGHUP", 2 => "SIGINT", 3 => "SIGQUIT", 4 => "SIGILL", 5 => "SIGTRAP", 6 => "SIGABRT", 7 => "SIGBUS", 8 => "SIGFPE", 9 => "SIGKILL", 10 => "SIGUSR1", 11 => "SIGSEGV", 12 => "SIGUSR2", 13 => "SIGPIPE", 14 => "SIGALRM", 15 => "SIGTERM", # 16 unused? 17 => "SIGCHLD", 18 => "SIGCONT", 19 => "SIGSTOP", 20 => "SIGTSTP", 21 => "SIGTTIN", 22 => "SIGTTOU", 23 => "SIGURG", 24 => "SIGXCPU", 25 => "SIGXFSZ", 26 => "SIGVTALRM", 27 => "SIGPROF" }
- RESCUE_RETRY_ATTEMPTS =
5
Instance Method Summary (collapse)
-
- (SSH) initialize(configuration = {})
constructor
A new instance of SSH.
Methods included from Private
#base_options, #gateway_options, #log_header, #process_key, #process_keys, #ssh_options, #tag
Methods included from Upload
Methods included from File
Methods included from Exec
Methods included from Download
Methods included from Core
#close, #close_gateway, #close_ssh, #do_proxy?, #gateway, #on_retry, #scp, #sftp, #ssh
Methods included from Console
Methods included from Command
#console_command, #proxy_command
Methods included from Bootstrap
Methods inherited from Base
build_config, #config, #direct_log, hash_config, log_and_raise, #log_and_raise
Constructor Details
- (SSH) initialize(configuration = {})
Returns a new instance of SSH
158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/ztk/ssh.rb', line 158 def initialize(configuration={}) super({ :forward_agent => true, :compression => false, :user_known_hosts_file => '/dev/null', :timeout => 60, :ignore_exit_status => false, :request_pty => true, :exit_code => 0, :silence => false }, configuration) end |