Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4798841

Browse files
authored
Merge pull request #4042 from cdr/jsjoeio-ssh-vscode
docs(guide): add ssh into code-server on vs code
2 parents b5afb05 + efbfe06 commit 4798841

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

‎docs/guide.md‎

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
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)
19+
- [Option 1: cloudflared tunnel](#option-1-cloudflared-tunnel)
20+
- [Option 2: ngrok tunnel](#option-2-ngrok-tunnel)
1821

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

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

372375
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+
[![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)
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+
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),
391+
392+
```bash
393+
sudo service ssh start
394+
sudo passwd {user} # replace user with your code-server user
395+
````
396+
397+
### Option 1: cloudflared tunnel
398+
399+
[![Cloudflared](https://img.shields.io/badge/Cloudflared-E4863B?style=for-the-badge&logo=cloudflare&logoColor=ffffff)](https://github.com/cloudflare/cloudflared)
400+
401+
1. Install [cloudflared](https://github.com/cloudflare/cloudflared#installing-cloudflared) on your local computer
402+
2. Then go to `~/.ssh/config` and add the following:
403+
404+
```shell
405+
Host *.trycloudflare.com
406+
HostName %h
407+
User root
408+
Port 22
409+
ProxyCommand "cloudflared location" access ssh --hostname %h
410+
```
411+
412+
3. Run `cloudflared tunnel --url ssh://localhost:22` on the remote server
413+
414+
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`
415+
416+
### Option 2: ngrok tunnel
417+
418+
[![Ngrok](https://img.shields.io/badge/Ngrok-1F1E37?style=for-the-badge&logo=ngrok&logoColor=ffffff)](https://ngrok.com/)
419+
420+
1. Make a new account for ngrok [here](https://dashboard.ngrok.com/login)
421+
422+
2. Now, get the ngrok binary with `wget` and unzip it with `unzip`:
423+
424+
```bash
425+
wget "https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip"
426+
unzip "ngrok-stable-linux-amd64.zip"
427+
```
428+
429+
5. Then, go to [dashboard.ngrok.com](https://dashboard.ngrok.com) and go to the `Your Authtoken` section.
430+
6. Copy the Authtoken shown there.
431+
7. Now, go to the folder where you unzipped ngrok and store the Authtoken from the ngrok Dashboard.
432+
433+
```bash
434+
./ngrok authtoken YOUR_AUTHTOKEN # replace YOUR_AUTHTOKEN with the ngrok authtoken.
435+
```
436+
437+
8. Now, forward port 22, which is the SSH port with this command:
438+
439+
```bash
440+
./ngrok tcp 22
441+
```
442+
443+
Now, you get a screen in the terminal like this:
444+
445+
```output
446+
ngrok by @inconshreveable(Ctrl+C to quit)
447+
448+
Session Status online
449+
Account {Your name} (Plan: Free)
450+
Version 2.3.40
451+
Region United States (us)
452+
Web Interface http://127.0.0.1:4040
453+
Forwarding tcp://0.tcp.ngrok.io:19028 -> localhost:22
454+
```
455+
456+
Copy the forwarded link `0.tcp.ngrok.io` and remember the port number `19028`. Type this on your local Visual Studio Code:
457+
458+
```bash
459+
ssh user@0.tcp.ngrok.io -p 19028
460+
```
461+
462+
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)

AltStyle によって変換されたページ (->オリジナル) /