lib/bard/base.rb in bard-0.45.1 vs lib/bard/base.rb in bard-0.46.0
- old
+ new
@@ -27,12 +27,14 @@
end
def ssh_command server, command, home: false
server = @config.servers[server.to_sym]
uri = URI.parse("ssh://#{server.ssh}")
+ ssh_key = server.ssh_key ? "-i #{server.ssh_key} " : ""
+ command = "#{server.env} #{command}" if server.env
command = "cd #{server.path} && #{command}" unless home
- command = "ssh -tt #{"-p#{uri.port} " if uri.port}#{uri.user}@#{uri.host} '#{command}'"
+ command = "ssh -tt #{ssh_key}#{"-p#{uri.port} " if uri.port}#{uri.user}@#{uri.host} '#{command}'"
if server.gateway
uri = URI.parse("ssh://#{server.gateway}")
command = "ssh -tt #{" -p#{uri.port} " if uri.port}#{uri.user}@#{uri.host} \"#{command}\""
end
command
@@ -43,16 +45,18 @@
uri = URI.parse("ssh://#{server.gateway}")
port = uri.port ? "-p#{uri.port}" : ""
gateway = server.gateway ? "-oProxyCommand='ssh #{port} #{uri.user}@#{uri.host} -W %h:%p'" : ""
+ ssh_key = server.ssh_key ? "-i #{server.ssh_key}" : ""
+
uri = URI.parse("ssh://#{server.ssh}")
port = uri.port ? "-P#{uri.port}" : ""
from_and_to = [path, "#{uri.user}@#{uri.host}:#{server.path}/#{path}"]
from_and_to.reverse! if direction == :from
- command = "scp #{gateway} #{port} #{from_and_to.join(" ")}"
+ command = "scp #{gateway} #{ssh_key} #{port} #{from_and_to.join(" ")}"
run_crucial command
end
def rsync direction, server, path
@@ -60,12 +64,13 @@
uri = URI.parse("ssh://#{server.gateway}")
port = uri.port ? "-p#{uri.port}" : ""
gateway = server.gateway ? "-oProxyCommand=\"ssh #{port} #{uri.user}@#{uri.host} -W %h:%p\"" : ""
+ ssh_key = server.ssh_key ? "-i #{server.ssh_key}" : ""
uri = URI.parse("ssh://#{server.ssh}")
port = uri.port ? "-p#{uri.port}" : ""
- ssh = "-e'ssh #{port} #{gateway}'"
+ ssh = "-e'ssh #{ssh_key} #{port} #{gateway}'"
dest_path = path.dup
dest_path = "./#{dest_path}"
from_and_to = [dest_path, "#{uri.user}@#{uri.host}:#{server.path}/#{path}"]
from_and_to.reverse! if direction == :from