lib/ztk/ssh.rb in ztk-0.0.16 vs lib/ztk/ssh.rb in ztk-0.0.17
- old
+ new
@@ -167,12 +167,12 @@
# config.user = ENV["USER"]
# config.host_name = "127.0.0.1"
# end
# puts ssh.exec("hostname -f").inspect
def exec(command, options={})
- log(:info) { "exec(#{command.inspect}, #{options.inspect})" }
log(:debug) { "config(#{@config.inspect})" }
+ log(:info) { "exec(#{command.inspect}, #{options.inspect})" }
options = OpenStruct.new({ :silence => false }.merge(options))
log(:debug) { "options(#{options.inspect})" }
output = ""
@@ -215,12 +215,12 @@
# end
# local = File.expand_path(File.join(ENV["HOME"], ".ssh", "id_rsa.pub"))
# remote = File.expand_path(File.join("/tmp", "id_rsa.pub"))
# ssh.upload(local, remote)
def upload(local, remote)
- log(:info) { "upload(#{local.inspect}, #{remote.inspect})" }
log(:debug) { "config(#{@config.inspect})" }
+ log(:info) { "upload(#{local.inspect}, #{remote.inspect})" }
sftp.upload!(local.to_s, remote.to_s) do |event, uploader, *args|
case event
when :open
log(:debug) { "upload(#{args[0].local} -> #{args[0].remote})" }
@@ -252,12 +252,12 @@
# end
# local = File.expand_path(File.join("/tmp", "id_rsa.pub"))
# remote = File.expand_path(File.join(ENV["HOME"], ".ssh", "id_rsa.pub"))
# ssh.download(remote, local)
def download(remote, local)
- log(:info) { "download(#{remote.inspect}, #{local.inspect})" }
log(:debug) { "config(#{@config.inspect})" }
+ log(:info) { "download(#{remote.inspect}, #{local.inspect})" }
sftp.download!(remote.to_s, local.to_s) do |event, downloader, *args|
case event
when :open
log(:debug) { "download(#{args[0].remote} -> #{args[0].local})" }
@@ -279,11 +279,10 @@
private
# Builds our SSH console command.
def console_command
log(:debug) { "console_command" }
- log(:debug) { "config(#{@config.inspect})" }
command = [ "ssh" ]
command << [ "-q" ]
command << [ "-A" ]
command << [ "-o", "UserKnownHostsFile=/dev/null" ]
@@ -300,11 +299,10 @@
end
# Builds our SSH proxy command.
def proxy_command
log(:debug) { "proxy_command" }
- log(:debug) { "config(#{@config.inspect})" }
if !@config.proxy_user
message = "You must specify an proxy user in order to SSH proxy."
log(:fatal) { message }
raise SSHError, message
@@ -333,10 +331,9 @@
end
# Builds our SSH options hash.
def ssh_options
log(:debug) { "ssh_options" }
- log(:debug) { "config(#{@config.inspect})" }
options = {}
# These are plainly documented on the Net::SSH config class.
options.merge!(:encryption => @config.encryption) if @config.encryption