Skip to content

Commit 6f42a24

Browse files
committed
docs(guide): add ssh into code-server on vs code
1 parent 6c6446f commit 6f42a24

File tree

1 file changed

+72
-1
lines changed

1 file changed

+72
-1
lines changed

docs/guide.md

+72-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ we recommend using another method, such as [Let's Encrypt](#let-encrypt) instead
8888
# This is the same as the above SSH command, but it runs in the background
8989
# continuously. Be sure to add `mutagen daemon start` to your ~/.bashrc to
9090
# start the mutagen daemon when you open a shell.
91-
91+
9292
mutagen forward create --name=code-server tcp:127.0.0.1:8080 < instance-ip > :tcp:127.0.0.1:8080
9393
```
9494

@@ -370,3 +370,74 @@ module.exports = {
370370
3. access app at `<code-server-root>/absproxy/3454` e.g. `http://localhost:8080/absproxy/3454`
371371

372372
Read more about `publicPath` in the [Vue.js docs](https://cli.vuejs.org/config/#publicpath)
373+
374+
## SSH into code-server on VS Code
375+
376+
[![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) [![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)
377+
378+
Follow these steps where code-server is running:
379+
1. Get `OpenSSH-Server`, `wget`, and `unzip` before getting ngrok. Also, run `sudo apt update` so you get the latest versions.
380+
```bash
381+
sudo apt update
382+
sudo apt install wget unzip openssh-server
383+
```
384+
2. Start OpenSSH-Server and set the password of your computer. Eg. If you use a Railway deployment, the user is `coder` and so, the command to change the password would be `sudo passwd coder`.
385+
```bash
386+
sudo service ssh start
387+
sudo passwd {user} # replace user with your code-server user
388+
```
389+
390+
[![Cloudflared](https://img.shields.io/badge/Cloudflared-E4863B?style=for-the-badge&logo=cloudflare&logoColor=ffffff)](https://github.com/cloudflare/cloudflared)
391+
392+
1. Install [cloudflared](https://github.com/cloudflare/cloudflared#installing-cloudflared) on your local computer
393+
2. Then go to `~/.ssh/config` and add the following:
394+
```shell
395+
Host *.trycloudflare.com
396+
HostName %h
397+
User root
398+
Port 22
399+
ProxyCommand "cloudflared location" access ssh --hostname %h
400+
```
401+
3. Run `cloudflared tunnel --url ssh://localhost:22` on the remote server
402+
403+
3. Finally on Visual Studio Code, run `ssh coder@https://your-link.trycloudflare.com` or `ssh [email protected]`
404+
405+
406+
[![Ngrok](https://img.shields.io/badge/Ngrok-1F1E37?style=for-the-badge&logo=ngrok&logoColor=ffffff)](https://ngrok.com/)
407+
408+
1. Make a new account for ngrok [here](https://dashboard.ngrok.com/login)
409+
410+
4. Now, get the ngrok binary with `wget` and unzip it with `unzip`:
411+
```bash
412+
wget "https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip"
413+
unzip "ngrok-stable-linux-amd64.zip"
414+
```
415+
5. Then, go to [dashboard.ngrok.com](https://dashboard.ngrok.com) and go to the `Your Authtoken` section.
416+
6. Copy the Authtoken shown there.
417+
7. Now, go to the folder where you unzipped ngrok and store the Authtoken from the ngrok Dashboard.
418+
```bash
419+
./ngrok authtoken YOUR_AUTHTOKEN # replace YOUR_AUTHTOKEN with the ngrok authtoken.
420+
```
421+
8. Now, forward port 22, which is the SSH port with this command:
422+
```bash
423+
./ngrok tcp 22
424+
```
425+
Now, you get a screen in the terminal like this:
426+
427+
```output
428+
ngrok by @inconshreveable(Ctrl+C to quit)
429+
430+
Session Status online
431+
Account {Your name} (Plan: Free)
432+
Version 2.3.40
433+
Region United States (us)
434+
Web Interface http://127.0.0.1:4040
435+
Forwarding tcp://0.tcp.ngrok.io:19028 -> localhost:22
436+
```
437+
438+
Copy the forwarded link `0.tcp.ngrok.io` and remember the port number `19028`. Type this on your local Visual Studio Code:
439+
440+
```bash
441+
ssh [email protected] -p 19028
442+
```
443+
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.

0 commit comments

Comments
 (0)