diff --git a/lib/kamal/commands/app/execution.rb b/lib/kamal/commands/app/execution.rb index 4434c26aa..1e4b42e5a 100644 --- a/lib/kamal/commands/app/execution.rb +++ b/lib/kamal/commands/app/execution.rb @@ -20,8 +20,8 @@ def execute_in_new_container(*command, interactive: false, env:) *command end - def execute_in_existing_container_over_ssh(*command, env:) - run_over_ssh execute_in_existing_container(*command, interactive: true, env: env), host: host + def execute_in_existing_container_over_ssh(*command, env:) + run_over_ssh execute_in_existing_container(*command, interactive: true, env: env), host: host, interactive: true end def execute_in_new_container_over_ssh(*command, env:) diff --git a/lib/kamal/commands/base.rb b/lib/kamal/commands/base.rb index 7521780ad..c18efb22c 100644 --- a/lib/kamal/commands/base.rb +++ b/lib/kamal/commands/base.rb @@ -10,14 +10,16 @@ def initialize(config) @config = config end - def run_over_ssh(*command, host:) + def run_over_ssh(*command, host:, interactive: false) "ssh".tap do |cmd| if config.ssh.proxy && config.ssh.proxy.is_a?(Net::SSH::Proxy::Jump) cmd << " -J #{config.ssh.proxy.jump_proxies}" elsif config.ssh.proxy && config.ssh.proxy.is_a?(Net::SSH::Proxy::Command) cmd << " -o ProxyCommand='#{config.ssh.proxy.command_line_template}'" end - cmd << " -t #{config.ssh.user}@#{host} -p #{config.ssh.port} '#{command.join(" ").gsub("'", "'\\\\''")}'" + cmd << " -tt" if interactive # Add -tt for interactive sessions + cmd << " #{config.ssh.user}@#{host} -p #{config.ssh.port}" + cmd << " '#{command.join(" ").gsub("'", "'\\\\''")}'" unless interactive end end