Class: LSync::Shells::SSH

Inherits:
LSync::Shell show all
Defined in:
lib/lsync/shells/ssh.rb

Overview

SSH shell provides access to a remote server using SSH.

Instance Method Summary collapse

Methods inherited from LSync::Shell

#connect, #ruby_command

Constructor Details

#initialize(options = {}) ⇒ SSH

Returns a new instance of SSH.


27
28
29
# File 'lib/lsync/shells/ssh.rb', line 27

def initialize(options = {})
	super(options[:command] || "ssh", options)
end

Instance Method Details

#command_argumentsObject

The connection options for ssh

`:port`

The remote port to use.

`:key`

A specific key file to use.

`:keys`

A specific array of key files to use.

`:timeout`

How long to wait until connection fails if no response is received.

`:compression`

Enable compression.

`:user`

Connect as a specific user.


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/lsync/shells/ssh.rb', line 38

def command_arguments
	args = []

	@options.each do |k,v|
		case(k.to_sym)
		when :port
			args += ['-p', v.to_s]
		when :key
			args += ['-i', v]
		when :keys
			v.each { |key_path| args += ['-i', key_path] } 
		when :timeout
			args += ['-o', "ConnectTimeout #{v.to_i}".to_cmd]
		when :compression
			args += ['-C'] if v
		when :user
			args += ['-l', v.to_s]
		end
	end

	return args
end

#connection_command(server, arguments = []) ⇒ Object


61
62
63
# File 'lib/lsync/shells/ssh.rb', line 61

def connection_command(server, arguments = [])
	super(server, arguments + command_arguments)
end