Since I introduced dashboard
in our PaaS system, my colleagues complained a lot about that it was unstable, often disconnected and difficult to transfer files. It is good to know that the dashboard is widely used in our system and developer want it to have more features and stability.
There are two parts to this blog. The former is about usage and the latter is how it works.
Self-hosted uptermd
is deployed in a small VPS. It can’t withstand a big storm, so use it wisely.
I’ve extended the upterm
code to support VSCode Remote SSH
. Please feel free to give an issue or pull requests.
https://github.com/corvofeng/upterm
Upterm usage
Installation
1 | bash <(curl -sL http://corvo.fun/scripts/upterm.sh) |
Usage
Copy URI to the browser:
Open it in the terminal:
When you see this icon, it means the remote connection has been established.
Open Projects
Full Functional Terminal
There is a full functional termianl in the VSCode, you can manipulate the host inside it.
Local port forward
VSCode also support port forward, which allows you access the remote port from localhost.
How it works
You could roughly assume that this tool has the functionality of openssh-server+frp
What upterm do
Here are two machines, one of them opened a upterm server, the other is the client to connect to the server.
upterm is an alternateive for tmate, upterm做了几个工作:
- Launch a OpenSSH server
- Connect the uptermd, obtain a session id, and print it.
- User will connect the server by session id.
You can refer to progress of upterm.
Remote SSH
VSCode supports remote ssh, which is a ssh client that can connect to the remote server.
Combine them
Upterm already allow us to connect by OpenSSH protocol, it means we can use VSCode over it.
When we use VSCode Remote, it works like this:
1 | ssh -T -D 1234 192.168.101.135 -p 2224 bash |
ssh -T 192.168.101.135 -p 2224 bash
will disable pseudo-terminal allocation, only run bash in commandssh -D 1234 xxxxx
means there will be a socks5 port in this server, please refer to OpenSSH Port Forwarding
As long as we create an OpenSSH server that allows VSCode connections, we are good to go. You may refer to this gist file.
https://gist.github.com/corvofeng/45c01edd33fa750e31653a90b1c4cdec
BottleNeck
There are several bottlenecks in Upterm.
- Every time we have a new container, user need to download code-server and uptermd.
- Every time we have a new container, user need to create their own config
- There are too many session ids, and VSCode keep them all
- Currently, VSCode Remote doesn’t support Alpine Linux, so we can’t use it in Alpine linux server
Compared to Gitpod, this project just works, but it doesn’t work well:
- The configuration need to share between multiple containers
- We need OpenID or OAuth for internal use in the enterprise
- Currently, it does not support VSCode web, while Gitpod already supports it.
Related projects
When I firstly introduced Dashboard to the PaaS System. I’d like to let user use local ssh or VSCode to connect it. I have done a lot of research on this