Skip to content

Commit 0906b91

Browse files
committedAug 26, 2021
docs(guide): add ssh into code-server on vs code
1 parent 6c6446f commit 0906b91

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed
 

‎docs/guide.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- [Stripping `/proxy/<port>` from the request path](#stripping-proxyport-from-the-request-path)
1616
- [Proxying to create a React app](#proxying-to-create-a-react-app)
1717
- [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)
1819

1920
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
2021

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

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