Millet Porridge

English version of https://corvo.myseu.cn

0%

Upterm Series 1: Support VSCode SSH

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做了几个工作:

  1. Launch a OpenSSH server
  2. Connect the uptermd, obtain a session id, and print it.
  3. 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
  1. ssh -T 192.168.101.135 -p 2224 bash will disable pseudo-terminal allocation, only run bash in command
  2. ssh -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.

  1. Every time we have a new container, user need to download code-server and uptermd.
  2. Every time we have a new container, user need to create their own config
  3. There are too many session ids, and VSCode keep them all
  4. 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:

  1. The configuration need to share between multiple containers
  2. We need OpenID or OAuth for internal use in the enterprise
  3. Currently, it does not support VSCode web, while Gitpod already supports it.

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

Change Dashboard to fit internal PaaS System

  1. 基于Kubernetes的PaaS平台提供dashboard支持的一种方案
  2. Kubernetes Dashboard定制化简介

Gitpod使用与简单原理分析

tmate service

VSCode Remote in Android