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

mosh does not work with ssh gateway #10440

Open
axonasif opened this issue Jun 2, 2022 · 18 comments
Open

mosh does not work with ssh gateway #10440

axonasif opened this issue Jun 2, 2022 · 18 comments
Labels
component: ssh gateway feature: mobile / tablet app feature: ssh gitpod for gitpod For tagging issues that will improve Gitpod for internal Gitpod use. meta: never-stale This issue can never become stale team: IDE

Comments

@axonasif
Copy link
Member

axonasif commented Jun 2, 2022

Bug description

Being able to use mosh would be very helpful to overcome latency issues with SSH. I might be able to use it via local-companion but that's too much effort to put each time. Tailscale should also work (nope), but again, that will make the latency even worse.

Steps to reproduce

  • Open a workspace
  • Run sudo install-packages mosh so that we have mosh server on our workspace
  • From gitpod dashboard, copy the ssh address for workspace
  • Connect with mosh command from your PC
  • See the following screen:

Screenshot 2022-06-03 at 12 44 51 AM

Screenshot 2022-06-03 at 12 46 06 AM

Workspace affected

No response

Expected behavior

No response

Example repository

No response

Anything else?

No response

@loujaybee
Copy link
Member

Thanks @axonasif ! Not sure why this doesn't work, but it can be looked into, I dropped the bug tag for now, as not sure it was something we said we'd previously supported (though it would be nice to). Any details, you or others could find when debugging about why it's not connecting would be useful! 🙏

@iQQBot
Copy link
Contributor

iQQBot commented Jun 3, 2022

I'm afraid there's no way around this. mosh expects the ssh server to be on the public network, or at least the firewall to be able to directly penetrate the specified UDP port, but that's not possible in gitpod

@iQQBot iQQBot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 8, 2022
@ghuntley ghuntley reopened this Aug 2, 2022
@ghuntley ghuntley added the meta: never-stale This issue can never become stale label Aug 2, 2022
@mrzarquon
Copy link
Contributor

you can get around the UDP limitation using tailscale, but since we don't support tailscale ssh on the workspace, you end using a gitpod ssh gateway session to start the mosh-server but then connect the mosh-client via the tailscale IP / port / session token

@abitrolly
Copy link

@iQQBot why allowing UDP traffic Kubernets LoadBalancer policy won't work? Not sure what Gitpod is using, but I guess it is here https://github.com/gitpod-io/gitpod/blob/main/install/installer/pkg/common/networkpolicies.go

@iQQBot
Copy link
Contributor

iQQBot commented Nov 9, 2022

@iQQBot why allowing UDP traffic Kubernets LoadBalancer policy won't work? Not sure what Gitpod is using, but I guess it is here https://github.com/gitpod-io/gitpod/blob/main/install/installer/pkg/common/networkpolicies.go

Unfortunately, this doesn't work because mossh expects the server to have a fixed port for authentication

@abitrolly
Copy link

@iQQBot mosh allows to specify the port, so I guess it can be fixed. So what it should do?

@abitrolly
Copy link

@iQQBot wdyt?

@iQQBot
Copy link
Contributor

iQQBot commented Nov 21, 2022

mosh allows to specify the port, so I guess it can be fixed. So what it should do?

Unfortunately we can't do this, there is not only one workspace in a node, so the public IP and workspace are not one-to-one, and there is no way to solve the mapping problem by opening the port

Unless we use UDP hole-punching, but this requires modifying the mosh source code

@axonasif
Copy link
Member Author

axonasif commented Nov 21, 2022

@iQQBot we appreciate you sharing all the technical/cost related issues that this may have. 🙏

But as an user who's looking to default to SSH for Gitpod usage, this is a big blocker. Having this ability would make SSH more sane to use with Gitpod. ssh-gateway is such an amazing capability Gitpod got that unlocks many possibilities, now only if mosh worked with it, then nothing like it.

Or maybe in the future if we have a client-side gp CLI with features of local-companion but with UDP port forwarding support. That'd work too.

@axonasif axonasif added the gitpod for gitpod For tagging issues that will improve Gitpod for internal Gitpod use. label Nov 21, 2022
@abitrolly
Copy link

@iQQBot I still don't understand. How does SSH attach to the specified workspace then, if there is no IP?

@iQQBot
Copy link
Contributor

iQQBot commented Nov 21, 2022

@iQQBot I still don't understand. How does SSH attach to the specified workspace then, if there is no IP?

We have a component called ssh gateway, which you can simply think of as nginx, that resolves usernames and credentials and routes them to the correct workspace, so there is no public IP for each workspace

@axonasif
Copy link
Member Author

I assume #459 is the main issue?

@abitrolly
Copy link

We have a component called ssh gateway, which you can simply think of as nginx, that resolves usernames and credentials and routes them to the correct workspace, so there is no public IP for each workspace

Found this diagram here.

image

If I have multiple workspaces open, how SSH Gateway knows which one to forward to? IP is the same, user name is the same, SSH key is the same.

@andreafalzetti
Copy link
Contributor

@abitrolly each workspace has a different workspace ID, https://<WORKSPACE_ID>.<CLUSTER>.gitpod.io/ the SSH connection cmd is ssh '<WORKSPACE_ID>@<WORKSPACE_ID>.ssh.<CLUSTER>.gitpod.io'

@abitrolly
Copy link

@andreafalzetti mosh uses user@ too at least for initial connection.

Usage: /usr/bin/mosh [options] [--] [user@]host [command...]
...

So to make traffic pass LoadBalancer should allow UDP packets to travel to SSH Gateway, and then the gateway needs to figure out from which user the packet comes from. I am not sure how it is done for SSH. SSH Gateway then should be running SSH server to terminate secure connection, but then traffic to workspace will be unencrypted. How does that work?

@iQQBot
Copy link
Contributor

iQQBot commented Nov 22, 2022

SSH gateway no to terminate secure connection, it will start a new ssh connect with workspace using different private key

for mosh, it's not, the username only use for ssh, this is in order to start mosh-server in server, after mosh-server is start, it will disconnect ssh connection, and direct using mosh-server, here, they negotiate another set of aes keys and then communicate directly with that set of keys; simply put, mosh uses ssh for

  1. start mosh-server
  2. get the IP address of the server
  3. negotiate the communication key

@abitrolly
Copy link

I mean SSH Gateway is kind of https://en.wikipedia.org/wiki/TLS_termination_proxy It terminates SSH connection - meaning it doesn't forward it, and initiates new SSH connection instead.

So for mosh the SSH Gateway can not terminate mosh connection, because that would mean mosh-server would run on the gateway and will forward events from gateway's terminal. So there should be some kind of proxy for mosh, which will forward the UDP traffic depending on communication key the client is using.

Can SSH gateway already read the communication key from mosh negotiation step?

@abitrolly
Copy link

There is a related issue in mosh mobile-shell/mosh#970

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: ssh gateway feature: mobile / tablet app feature: ssh gitpod for gitpod For tagging issues that will improve Gitpod for internal Gitpod use. meta: never-stale This issue can never become stale team: IDE
Projects
None yet
Development

No branches or pull requests

7 participants