Class: Pipes::SshPipe
- Inherits:
-
SystemPipe
- Object
- SystemPipe
- Pipes::SshPipe
- Defined in:
- lib/ssh_pipe.rb
Constant Summary
Constants inherited from SystemPipe
Pipes::SystemPipe::NUMBER_ONLY_REGEX
Instance Attribute Summary collapse
-
#hosts ⇒ Object
readonly
Returns the value of attribute hosts.
-
#initialization_command ⇒ Object
readonly
Returns the value of attribute initialization_command.
Attributes inherited from SystemPipe
#abandoned_pipes_count, #initial_command, #pipe
Instance Method Summary collapse
- #close ⇒ Object
- #initial_ssh_command(host, user) ⇒ Object
-
#initialize(ssh_hosts, user = nil) ⇒ SshPipe
constructor
A new instance of SshPipe.
- #ssh_options ⇒ Object
- #user_specified(user) ⇒ Object
Methods inherited from SystemPipe
#backup_file, #backup_timestamp, #close_with_timeout, #cp, #current_time, #ensure_started, #extract_number_from_string, #flush_until, #follow_file, #follow_file_command, #make_path, #puts_command_read_number, #puts_limit_one_line, #puts_with_output_to_dev_null, #retry_after_timeout, #retry_pipe, #run_command_and_ensure_return_code, #start_pipe, #write_file
Constructor Details
#initialize(ssh_hosts, user = nil) ⇒ SshPipe
Returns a new instance of SshPipe.
6 7 8 9 10 11 12 13 14 |
# File 'lib/ssh_pipe.rb', line 6 def initialize(ssh_hosts, user = nil) @hosts = ssh_hosts.clone @initialization_command = initial_ssh_command(ssh_hosts.shift,user) ssh_hosts.each do |host| @initialization_command += "ssh #{host} " end super(initialization_command) end |
Instance Attribute Details
#hosts ⇒ Object (readonly)
Returns the value of attribute hosts.
4 5 6 |
# File 'lib/ssh_pipe.rb', line 4 def hosts @hosts end |
#initialization_command ⇒ Object (readonly)
Returns the value of attribute initialization_command.
4 5 6 |
# File 'lib/ssh_pipe.rb', line 4 def initialization_command @initialization_command end |
Instance Method Details
#close ⇒ Object
38 39 40 41 |
# File 'lib/ssh_pipe.rb', line 38 def close puts "exit" super end |
#initial_ssh_command(host, user) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/ssh_pipe.rb', line 16 def initial_ssh_command(host,user) ssh_command = "ssh #{}" ssh_command += "#{user}@" if user_specified(user) ssh_command += "#{host} " ssh_command end |
#ssh_options ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/ssh_pipe.rb', line 24 def = "-o 'StrictHostKeyChecking no' " += "-o 'UserKnownHostsFile=/dev/null' " += "-o 'ConnectionAttempts 5' " += "-o 'CheckHostIP no' " += "-o 'PasswordAuthentication no' " += "-o 'ForwardAgent true' " end |
#user_specified(user) ⇒ Object
34 35 36 |
# File 'lib/ssh_pipe.rb', line 34 def user_specified(user) user && (not user.empty?) end |