|
15 | 15 | - [Stripping `/proxy/<port>` from the request path](#stripping-proxyport-from-the-request-path)
|
16 | 16 | - [Proxying to create a React app](#proxying-to-create-a-react-app)
|
17 | 17 | - [Proxying to a Vue app](#proxying-to-a-vue-app)
|
| 18 | +- [SSH into code-server on VS Code](#ssh-into-code-server-on-vs-code) |
| 19 | + - [Option 1: cloudflared tunnel](#option-1-cloudflared-tunnel) |
| 20 | + - [Option 2: ngrok tunnel](#option-2-ngrok-tunnel) |
18 | 21 |
|
19 | 22 | <!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
20 | 23 |
|
@@ -370,3 +373,93 @@ module.exports = {
|
370 | 373 | 3. access app at `<code-server-root>/absproxy/3454` e.g. `http://localhost:8080/absproxy/3454`
|
371 | 374 |
|
372 | 375 | Read more about `publicPath` in the [Vue.js docs](https://cli.vuejs.org/config/#publicpath)
|
| 376 | + |
| 377 | +## SSH into code-server on VS Code |
| 378 | + |
| 379 | +[](https://ohmyz.sh/) [](https://img.shields.io/badge/Terminal-2E2E2E?style=for-the-badge&logo=Windows+Terminal&logoColor=ffffff) [](vscode:extension/ms-vscode-remote.remote-ssh) |
| 380 | + |
| 381 | +Follow these steps where code-server is running: |
| 382 | + |
| 383 | +1. Install `openssh-server`, `wget`, and `unzip`. |
| 384 | + |
| 385 | +```bash |
| 386 | +# example for Debian and Ubuntu operating systems |
| 387 | +sudo apt update |
| 388 | +sudo apt install wget unzip openssh-server |
| 389 | +``` |
| 390 | + |
| 391 | +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), |
| 392 | + |
| 393 | +```bash |
| 394 | +sudo service ssh start |
| 395 | +sudo passwd {user} # replace user with your code-server user |
| 396 | +``` |
| 397 | + |
| 398 | +### Option 1: cloudflared tunnel |
| 399 | + |
| 400 | +[](https://github.com/cloudflare/cloudflared) |
| 401 | + |
| 402 | +1. Install [cloudflared](https://github.com/cloudflare/cloudflared#installing-cloudflared) on your local computer |
| 403 | +2. Then go to `~/.ssh/config` and add the following: |
| 404 | + |
| 405 | +```shell |
| 406 | +Host *.trycloudflare.com |
| 407 | +HostName %h |
| 408 | +User root |
| 409 | +Port 22 |
| 410 | +ProxyCommand "cloudflared location" access ssh --hostname %h |
| 411 | +``` |
| 412 | + |
| 413 | +3. Run `cloudflared tunnel --url ssh://localhost:22` on the remote server |
| 414 | + |
| 415 | +4. Finally on VS Code or any IDE that supports SSH, run `ssh coder@https://your-link.trycloudflare.com` or `ssh [email protected]` |
| 416 | + |
| 417 | +### Option 2: ngrok tunnel |
| 418 | + |
| 419 | +[](https://ngrok.com/) |
| 420 | + |
| 421 | +1. Make a new account for ngrok [here](https://dashboard.ngrok.com/login) |
| 422 | + |
| 423 | +2. Now, get the ngrok binary with `wget` and unzip it with `unzip`: |
| 424 | + |
| 425 | +```bash |
| 426 | +wget "https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip" |
| 427 | +unzip "ngrok-stable-linux-amd64.zip" |
| 428 | +``` |
| 429 | + |
| 430 | +5. Then, go to [dashboard.ngrok.com](https://dashboard.ngrok.com) and go to the `Your Authtoken` section. |
| 431 | +6. Copy the Authtoken shown there. |
| 432 | +7. Now, go to the folder where you unzipped ngrok and store the Authtoken from the ngrok Dashboard. |
| 433 | + |
| 434 | +```bash |
| 435 | +./ngrok authtoken YOUR_AUTHTOKEN # replace YOUR_AUTHTOKEN with the ngrok authtoken. |
| 436 | +``` |
| 437 | + |
| 438 | +8. Now, forward port 22, which is the SSH port with this command: |
| 439 | + |
| 440 | +```bash |
| 441 | +./ngrok tcp 22 |
| 442 | +``` |
| 443 | + |
| 444 | +Now, you get a screen in the terminal like this: |
| 445 | + |
| 446 | +```console |
| 447 | +ngrok by @inconshreveable(Ctrl+C to quit) |
| 448 | + |
| 449 | +Session Status online |
| 450 | +Account {Your name} (Plan: Free) |
| 451 | +Version 2.3.40 |
| 452 | +Region United States (us) |
| 453 | +Web Interface http://127.0.0.1:4040 |
| 454 | +Forwarding tcp://0.tcp.ngrok.io:19028 -> localhost:22 |
| 455 | +``` |
| 456 | + |
| 457 | +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: |
| 458 | + |
| 459 | +```bash |
| 460 | + |
| 461 | +``` |
| 462 | + |
| 463 | +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. |
| 464 | + |
| 465 | +Note: the port and the url provided by ngrok will change each time you run it so modify as needed. |
0 commit comments