Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] [Kamal 2] Pemission denied (publickey) only for interactive commands #1087

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/kamal/commands/app/execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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:)
Expand Down
6 changes: 4 additions & 2 deletions lib/kamal/commands/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we skipping the command here when not interactive?

end
end

Expand Down
Loading