Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The host prefix’s username is discarded, causing canonical deploy@host configurations to authenticate as the configured default user instead.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Updates local-registry SSH port forwarding to handle user@host server addresses and tolerate tunnel setup failures.
Changes:
- Strips the user prefix before hostname resolution.
- Logs rejected forwards and connection failures without aborting immediately.
- Adds focused port-forwarding tests.
[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or rungh pr ready --undo.
Click "Ready for review" or rungh pr readyto reengage.
| File | Description |
|---|---|
lib/kamal/cli/build/port_forwarding.rb |
Updates SSH connection and failure handling. |
test/cli/build/port_forwarding_test.rb |
Tests hostname parsing and recoverable failures. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| Thread.new do | ||
| begin | ||
| Net::SSH.start(host, ssh_options[:user], **ssh_options.except(:user)) do |ssh| | ||
| Net::SSH.start(host.to_s.split("@").last, ssh_options[:user], **ssh_options.except(:user)) do |ssh| |
talha7k
force-pushed
the
port-forwarding-user-host-and-existing-tunnel
branch
2 times, most recently
from
October 27, 2026 12:14
324ed4f to
2334211
Compare
talha7k
force-pushed
the
port-forwarding-user-host-and-existing-tunnel
branch
from
November 7, 2026 03:45
2334211 to
d28a3f3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Servers configured in the canonical
user@hostform broke deploys thatuse the local registry on 2.12.0.
Net::SSH.startreceived the raw hostfrom the config, so
deploy@203.0.113.10went togetaddrinfoverbatimand resolution failed with
getaddrinfo: Name or service not knownbeforea single image was built. SSHKit splits the user out when it connects for
the deploy commands themselves; the port forwarding setup skipped that
step. The prefix is now stripped before connecting, and authentication
still uses
ssh_options[:user].A rejected
tcpip-forwardalso aborted the deploy. That is exactly whathappens when the remote port is already bound — for example by an
operator-managed persistent
ssh -Rtunnel serving the local registry.The rejection is now logged ("Port forward rejected on ... tunnel may
already exist") and the deploy continues; a connection failure during
setup passes the same way instead of raising. If the registry really is
unreachable, the deploy still fails later with the registry error.
Repro on 2.12.0:
servers: [ "deploy@<ip>" ]with a remote builder and alocal registry, then
kamal deploy(orkamal app pull) — it dies withgetaddrinfo during "Setting up local registry port forwarding". With the
patch the same config forwards to the bare host and deploys.
Tests added for the
PortForwardingclass: the user prefix is strippedwhen connecting, and both a rejected forward and a failed connection are
logged without aborting the deploy.