-
Notifications
You must be signed in to change notification settings - Fork 887
feat(cli): implement ssh remote forward #8515
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
Conversation
// local address via SSH in a goroutine. | ||
// | ||
// Accepts a `cookieAddr` as the local address. | ||
func sshRemoteForward(ctx context.Context, stderr io.Writer, sshClient *gossh.Client, localAddr, remoteAddr net.Addr) (io.Closer, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for reviewers: moved from ssh.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add support for this with coder port-forward
?
cookie []byte | ||
} | ||
|
||
var remoteForwardRegex = regexp.MustCompile(`^(\d+):(.+):(\d+)$`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add a comment to clarify what this should match
This could also be done with a simple strings.Split()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add a comment to clarify what this should match
👍
This could also be done with a simple strings.Split()
Right, but with regexp we can check if ports are numbers :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, some nits in comments.
Thank you for raising this question, @bpmct. The main reason why it is paired with Also, if we want to forward multiple ports, then it is advised to run multiple Enabling remote forward as part of the "port-forward" will be tricky, as it means that "port-forward" must establish SSH connection with the workspace agent, contrary to local forward which just needs Tailscale/Wireguard. I see the following options:
I'm fine with implementing 2. and 3. in separate PRs. Option 3. might be a relatively tricky feature to implement. @bpmct Please let me know your thoughts! |
I see. My main concern is around feature discoverability since many will probably look in Otherwise, I think option 2 would be fine to embed a ssh server only if |
Absolutely, this is something I can easily do. It is a no-brainer.
I'm looking at these SSH flags:
If we're going to use an SSH connection, these flags may be required for
Alright, I'm going to finish work on |
Related: #6818
This PR enables remote forward (
ssh -R
) for the coder CLI to allow reverse TCP tunnels.Changes:
--remote-forward
flag (remote_port:local_address:local_port
)sshRemoteForward
for proxying traffictryPollWorkspaceAutostop
to prevent blocking when 2ssh -R
processes are trying to open the same remote portsshRemoteForward
tocli/remoteforward.go