From b4c5dc548e2b2d1aeb444d580d98f1813ece6d24 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Mon, 30 Aug 2021 10:58:43 -0700 Subject: [PATCH 1/6] Revert "revert: "docs(guide): add ssh into code-server on vs code" (#4060)" This reverts commit c0d62da127714fd57c51253750824094edaa1ec6. --- docs/guide.md | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/docs/guide.md b/docs/guide.md index 1f3314f5..c6b82379 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -15,6 +15,9 @@ - [Stripping `/proxy/` from the request path](#stripping-proxyport-from-the-request-path) - [Proxying to create a React app](#proxying-to-create-a-react-app) - [Proxying to a Vue app](#proxying-to-a-vue-app) +- [SSH into code-server on VS Code](#ssh-into-code-server-on-vs-code) + - [Option 1: cloudflared tunnel](#option-1-cloudflared-tunnel) + - [Option 2: ngrok tunnel](#option-2-ngrok-tunnel) @@ -370,3 +373,91 @@ module.exports = { 3. access app at `/absproxy/3454` e.g. `http://localhost:8080/absproxy/3454` Read more about `publicPath` in the [Vue.js docs](https://cli.vuejs.org/config/#publicpath) + +## SSH into code-server on VS Code + +[![SSH](https://img.shields.io/badge/SSH-363636?style=for-the-badge&logo=GNU+Bash&logoColor=ffffff)](https://ohmyz.sh/) [![Terminal](https://img.shields.io/badge/Terminal-2E2E2E?style=for-the-badge&logo=Windows+Terminal&logoColor=ffffff)](https://img.shields.io/badge/Terminal-2E2E2E?style=for-the-badge&logo=Windows+Terminal&logoColor=ffffff) [![Visual Studio Code](https://img.shields.io/badge/Visual_Studio_Code-007ACC?style=for-the-badge&logo=Visual+Studio+Code&logoColor=ffffff)](vscode:extension/ms-vscode-remote.remote-ssh) + +Follow these steps where code-server is running: + +1. Install `openssh-server`, `wget`, and `unzip`. + +```bash +# example for Debian and Ubuntu operating systems +sudo apt update +sudo apt install wget unzip openssh-server +``` + +2. Start the SSH server and set the password for your user, if you haven't already. If you use [deploy-code-server](https://github.com/cdr/deploy-code-server), + +```bash +sudo service ssh start +sudo passwd {user} # replace user with your code-server user +``` + +### Option 1: cloudflared tunnel + +[![Cloudflared](https://img.shields.io/badge/Cloudflared-E4863B?style=for-the-badge&logo=cloudflare&logoColor=ffffff)](https://github.com/cloudflare/cloudflared) + +1. Install [cloudflared](https://github.com/cloudflare/cloudflared#installing-cloudflared) on your local computer +2. Then go to `~/.ssh/config` and add the following: + +```shell +Host *.trycloudflare.com +HostName %h +User root +Port 22 +ProxyCommand "cloudflared location" access ssh --hostname %h +``` + +3. Run `cloudflared tunnel --url ssh://localhost:22` on the remote server + +4. Finally on VS Code or any IDE that supports SSH, run `ssh coder@https://your-link.trycloudflare.com` or `ssh coder@your-link.trycloudflare.com` + +### Option 2: ngrok tunnel + +[![Ngrok](https://img.shields.io/badge/Ngrok-1F1E37?style=for-the-badge&logo=ngrok&logoColor=ffffff)](https://ngrok.com/) + +1. Make a new account for ngrok [here](https://dashboard.ngrok.com/login) + +2. Now, get the ngrok binary with `wget` and unzip it with `unzip`: + +```bash +wget "https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip" +unzip "ngrok-stable-linux-amd64.zip" +``` + +5. Then, go to [dashboard.ngrok.com](https://dashboard.ngrok.com) and go to the `Your Authtoken` section. +6. Copy the Authtoken shown there. +7. Now, go to the folder where you unzipped ngrok and store the Authtoken from the ngrok Dashboard. + +```bash +./ngrok authtoken YOUR_AUTHTOKEN # replace YOUR_AUTHTOKEN with the ngrok authtoken. +``` + +8. Now, forward port 22, which is the SSH port with this command: + +```bash +./ngrok tcp 22 +``` + +Now, you get a screen in the terminal like this: + +```console +ngrok by @inconshreveable(Ctrl+C to quit) + +Session Status online +Account {Your name} (Plan: Free) +Version 2.3.40 +Region United States (us) +Web Interface http://127.0.0.1:4040 +Forwarding tcp://0.tcp.ngrok.io:19028 -> localhost:22 +``` + +Copy the forwarded link `0.tcp.ngrok.io` and remember the port number `19028`. Type this on your local Visual Studio Code: + +```bash +ssh user@0.tcp.ngrok.io -p 19028 +``` + +The port redirects you to the default SSH port 22, and you can then successfully connect to code-server by entering the password you set for the user. From 2c1aed239504305be7d4b516154045cebda4ceae Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Wed, 1 Sep 2021 14:00:59 -0700 Subject: [PATCH 2/6] fix: update tar version with resolution --- docs/guide.md | 4 +++- lib/vscode/package.json | 3 ++- lib/vscode/yarn.lock | 8 ++++---- package.json | 2 +- test/package.json | 2 +- test/yarn.lock | 8 ++++---- yarn.lock | 8 ++++---- 7 files changed, 19 insertions(+), 16 deletions(-) diff --git a/docs/guide.md b/docs/guide.md index c6b82379..c60d985a 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -454,10 +454,12 @@ Web Interface http://127.0.0.1:4040 Forwarding tcp://0.tcp.ngrok.io:19028 -> localhost:22 ``` -Copy the forwarded link `0.tcp.ngrok.io` and remember the port number `19028`. Type this on your local Visual Studio Code: +In this case, copy the forwarded link `0.tcp.ngrok.io` and remember the port number `19028`. Type this on your local Visual Studio Code: ```bash ssh user@0.tcp.ngrok.io -p 19028 ``` The port redirects you to the default SSH port 22, and you can then successfully connect to code-server by entering the password you set for the user. + +Note: the port and the url provided by ngrok will change each time you run it so modify as needed. diff --git a/lib/vscode/package.json b/lib/vscode/package.json index 1403dad8..6a7eff83 100644 --- a/lib/vscode/package.json +++ b/lib/vscode/package.json @@ -218,6 +218,7 @@ "elliptic": "^6.5.3", "nwmatcher": "^1.4.4", "chrome-remote-interface": "^0.30.0", - "glob-parent": "^5.1.2" + "glob-parent": "^5.1.2", + "tar": "^6.1.9" } } diff --git a/lib/vscode/yarn.lock b/lib/vscode/yarn.lock index e5170b96..4c8dadb1 100644 --- a/lib/vscode/yarn.lock +++ b/lib/vscode/yarn.lock @@ -8020,10 +8020,10 @@ tapable@^1.0.0, tapable@^1.1.3: resolved "https://registry.yarnpkg.com/tapable/-/tapable-1.1.3.tgz#a1fccc06b58db61fd7a45da2da44f5f3a3e67ba2" integrity sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA== -tar@^6.0.2: - version "6.0.5" - resolved "https://registry.yarnpkg.com/tar/-/tar-6.0.5.tgz#bde815086e10b39f1dcd298e89d596e1535e200f" - integrity sha512-0b4HOimQHj9nXNEAA7zWwMM91Zhhba3pspja6sQbgTpynOJf+bkjBnfybNYzbpLbnwXnbyB4LOREvlyXLkCHSg== +tar@^6.0.2, tar@^6.1.9: + version "6.1.11" + resolved "https://registry.yarnpkg.com/tar/-/tar-6.1.11.tgz#6760a38f003afa1b2ffd0ffe9e9abbd0eab3d621" + integrity sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA== dependencies: chownr "^2.0.0" fs-minipass "^2.0.0" diff --git a/package.json b/package.json index 03d7b8b8..6c70ada9 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "browserslist": "^4.16.5", "safe-buffer": "^5.1.1", "vfile-message": "^2.0.2", - "argon2/@mapbox/node-pre-gyp/tar": "^6.1.3", + "argon2/@mapbox/node-pre-gyp/tar": "^6.1.9", "path-parse": "^1.0.7" }, "dependencies": { diff --git a/test/package.json b/test/package.json index 4f87bc67..1996a5b0 100644 --- a/test/package.json +++ b/test/package.json @@ -19,6 +19,6 @@ "wtfnode": "^0.9.0" }, "resolutions": { - "argon2/@mapbox/node-pre-gyp/tar": "^6.1.3" + "argon2/@mapbox/node-pre-gyp/tar": "^6.1.9" } } diff --git a/test/yarn.lock b/test/yarn.lock index 2fa48122..9b729d37 100644 --- a/test/yarn.lock +++ b/test/yarn.lock @@ -4412,10 +4412,10 @@ symbol-tree@^3.2.4: resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw== -tar@^6.1.0, tar@^6.1.3: - version "6.1.6" - resolved "https://registry.yarnpkg.com/tar/-/tar-6.1.6.tgz#c23d797b0a1efe5d479b1490805c5443f3560c5d" - integrity sha512-oaWyu5dQbHaYcyZCTfyPpC+VmI62/OM2RTUYavTk1MDr1cwW5Boi3baeYQKiZbY2uSQJGr+iMOzb/JFxLrft+g== +tar@^6.1.0, tar@^6.1.9: + version "6.1.11" + resolved "https://registry.yarnpkg.com/tar/-/tar-6.1.11.tgz#6760a38f003afa1b2ffd0ffe9e9abbd0eab3d621" + integrity sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA== dependencies: chownr "^2.0.0" fs-minipass "^2.0.0" diff --git a/yarn.lock b/yarn.lock index f62997ef..ec7be87a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4882,10 +4882,10 @@ tar-stream@^2.1.4: inherits "^2.0.3" readable-stream "^3.1.1" -tar@^6.1.0, tar@^6.1.3: - version "6.1.6" - resolved "https://registry.yarnpkg.com/tar/-/tar-6.1.6.tgz#c23d797b0a1efe5d479b1490805c5443f3560c5d" - integrity sha512-oaWyu5dQbHaYcyZCTfyPpC+VmI62/OM2RTUYavTk1MDr1cwW5Boi3baeYQKiZbY2uSQJGr+iMOzb/JFxLrft+g== +tar@^6.1.0, tar@^6.1.9: + version "6.1.11" + resolved "https://registry.yarnpkg.com/tar/-/tar-6.1.11.tgz#6760a38f003afa1b2ffd0ffe9e9abbd0eab3d621" + integrity sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA== dependencies: chownr "^2.0.0" fs-minipass "^2.0.0" From 0529f52b9d72b7909fbdc07bc66c07a441a91efd Mon Sep 17 00:00:00 2001 From: Stefano Dissegna Date: Tue, 7 Sep 2021 12:16:19 +0200 Subject: [PATCH 3/6] compile extensions media --- ci/build/build-vscode.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build/build-vscode.sh b/ci/build/build-vscode.sh index faddf46e..d2f10d2a 100755 --- a/ci/build/build-vscode.sh +++ b/ci/build/build-vscode.sh @@ -10,7 +10,7 @@ main() { cd "$(dirname "${0}")/../.." cd lib/vscode - yarn gulp compile-build compile-extensions-build + yarn gulp compile-build compile-extensions-build compile-extension-media yarn gulp optimize --gulpfile ./coder.js if [[ $MINIFY ]]; then yarn gulp minify --gulpfile ./coder.js From b32b4edf3d1167f87cb3f4aaf1acd3d5378cefb3 Mon Sep 17 00:00:00 2001 From: Max <35831069+maxloh@users.noreply.github.com> Date: Thu, 9 Sep 2021 00:11:20 +0800 Subject: [PATCH 4/6] fix: run postinstall script explicitly with bash (#4116) Currently, Windows default script-shell (cmd) fails to run the postinstall script. This commit fixes the problem by running postinstall.sh explicitly with the default bash executable of the OS. Related: #1397 --- ci/build/build-release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build/build-release.sh b/ci/build/build-release.sh index fe788d7c..838c6551 100755 --- a/ci/build/build-release.sh +++ b/ci/build/build-release.sh @@ -48,7 +48,7 @@ bundle_code_server() { { "commit": "$(git rev-parse HEAD)", "scripts": { - "postinstall": "./postinstall.sh" + "postinstall": "bash ./postinstall.sh" } } EOF From b00afbc0349576028fb4055460144e57cf2073c4 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Wed, 8 Sep 2021 12:50:36 -0500 Subject: [PATCH 5/6] Resolve remote authority to initialize tunnel API (#4105) * Resolve remote authority to initialize tunnel API * Fix linting * Add comment --- .../extensions/browser/extensionService.ts | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/vscode/src/vs/workbench/services/extensions/browser/extensionService.ts b/lib/vscode/src/vs/workbench/services/extensions/browser/extensionService.ts index 1ab76641..dead7008 100644 --- a/lib/vscode/src/vs/workbench/services/extensions/browser/extensionService.ts +++ b/lib/vscode/src/vs/workbench/services/extensions/browser/extensionService.ts @@ -9,7 +9,7 @@ import { IWorkbenchExtensionEnablementService, IWebExtensionsScannerService } fr import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; -import { IExtensionService, IExtensionHost } from 'vs/workbench/services/extensions/common/extensions'; +import { IExtensionService, IExtensionHost, ExtensionHostKind, } from 'vs/workbench/services/extensions/common/extensions'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { IFileService } from 'vs/platform/files/common/files'; import { IProductService } from 'vs/platform/product/common/productService'; @@ -28,6 +28,7 @@ import { IExtensionManagementService } from 'vs/platform/extensionManagement/com import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { IExtensionManifestPropertiesService } from 'vs/workbench/services/extensions/common/extensionManifestPropertiesService'; import { IUserDataInitializationService } from 'vs/workbench/services/userData/browser/userDataInit'; +import { IRemoteExplorerService } from '../../remote/common/remoteExplorerService'; export class ExtensionService extends AbstractExtensionService implements IExtensionService { @@ -51,6 +52,7 @@ export class ExtensionService extends AbstractExtensionService implements IExten @ILifecycleService private readonly _lifecycleService: ILifecycleService, @IExtensionManifestPropertiesService extensionManifestPropertiesService: IExtensionManifestPropertiesService, @IUserDataInitializationService private readonly _userDataInitializationService: IUserDataInitializationService, + @IRemoteExplorerService private readonly _remoteExplorerService: IRemoteExplorerService ) { super( new ExtensionRunningLocationClassifier( @@ -75,7 +77,24 @@ export class ExtensionService extends AbstractExtensionService implements IExten // Initialize installed extensions first and do it only after workbench is ready this._lifecycleService.when(LifecyclePhase.Ready).then(async () => { await this._userDataInitializationService.initializeInstalledExtensions(this._instantiationService); - this._initialize(); + this._initialize().then(async () => { + try { + // This enables the `vscode.workspace.registerRemoteAuthorityResolver` API to be executed. + // + // It's specifically scoped to the "coder-link" scheme at the moment to reduce external + // dependency on forking VS Code functionality. + // + // The remote host doesn't resolve to an extension host like the API expects, but instead + // we only utilize the tunnel functionality. + const extHost = this._getExtensionHostManager(ExtensionHostKind.Remote); + const resolved = await extHost?.resolveAuthority('coder-link+web'); + if (resolved) { + this._remoteExplorerService.setTunnelInformation(resolved.tunnelInformation); + } + } catch (ex) { + this._logOrShowMessage(Severity.Error, nls.localize('link', "Failed to initialize remote Link authority: {0}", ex)); + } + }); }); this._initFetchFileSystem(); From 7a735014bb068d22fb21313b7563bc4c2238ff5a Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 8 Sep 2021 15:00:34 -0500 Subject: [PATCH 6/6] Push latest Docker tag along with version tag (#4120) --- ci/release-image/docker-bake.hcl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ci/release-image/docker-bake.hcl b/ci/release-image/docker-bake.hcl index 3ef2f0b4..cb55da69 100644 --- a/ci/release-image/docker-bake.hcl +++ b/ci/release-image/docker-bake.hcl @@ -12,6 +12,9 @@ group "default" { target "code-server" { dockerfile = "ci/release-image/Dockerfile" - tags = ["docker.io/codercom/code-server:${VERSION}"] + tags = [ + "docker.io/codercom/code-server:latest", + notequal("latest",VERSION) ? "docker.io/codercom/code-server:${VERSION}" : "", + ] platforms = ["linux/amd64", "linux/arm64"] }