Skip to content

Commit 3a1e3bc

Browse files
committed
Final revisions for the docs before release
🚀
1 parent e0dbd8f commit 3a1e3bc

File tree

2 files changed

+49
-41
lines changed

2 files changed

+49
-41
lines changed

ci/build/code-server.service

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ ExecStart=/usr/bin/code-server
88
Restart=always
99

1010
[Install]
11-
WantedBy=multi-user.target
11+
WantedBy=default.target

doc/guide.md

+48-40
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
- [1. Acquire a remote machine](#1-acquire-a-remote-machine)
66
- [Requirements](#requirements)
7-
- [Google Cloud Platform](#google-cloud-platform)
7+
- [Google Cloud](#google-cloud)
88
- [2. Install code-server](#2-install-code-server)
99
- [3. Expose code-server](#3-expose-code-server)
1010
- [SSH forwarding](#ssh-forwarding)
@@ -18,10 +18,10 @@
1818
This guide demonstrates how to setup and use code-server.
1919
To reiterate, code-server lets you run VS Code on a remote server and then access it via a browser.
2020

21-
See the [README](../README.md) for a general overview and the [FAQ](./FAQ.md) for further user docs.
21+
See [README.md](../README.md) for a general overview and [FAQ.md](./FAQ.md) for further user docs.
2222

2323
We'll walk you through acquiring a remote machine to run code-server on and then exposing `code-server` so you can
24-
easily access it.
24+
securely access it.
2525

2626
## 1. Acquire a remote machine
2727

@@ -35,9 +35,9 @@ For a good experience, we recommend at least:
3535
- 1 GB of RAM
3636
- 2 cores
3737

38-
You can use whatever linux distribution floats your boat but in this guide we assume Debian.
38+
You can use whatever linux distribution floats your boat but in this guide we assume Debian on Google Cloud.
3939

40-
### Google Cloud Platform
40+
### Google Cloud
4141

4242
For demonstration purposes, this guide assumes you're using a VM on GCP but you should be
4343
able to easily use any machine or VM provider.
@@ -47,19 +47,24 @@ free trial.
4747

4848
Once you've signed up and created a GCP project, create a new Compute Engine VM Instance.
4949

50-
1. Navigate to `Compute Engine -> VM Instances` on the sidebar
51-
2. Now click `Create Instance` to create a new instance
52-
3. Choose the region closest to you based on [gcping.com](http://www.gcping.com)
53-
4. Name it whatever you want
54-
5. Any zone is fine
55-
6. We'd recommend a `e2-standard-2` instance from the E2 series and General-purpose family
56-
- Add more vCPUs and memory as you prefer, you can edit after creating the instance as well
50+
1. Navigate to `Compute Engine -> VM Instances` on the sidebar.
51+
2. Now click `Create Instance` to create a new instance.
52+
3. Name it whatever you want.
53+
4. Choose the region closest to you based on [gcping.com](http://www.gcping.com).
54+
5. Any zone is fine.
55+
6. We'd recommend a `E2` series instance from the General-purpose family.
56+
- Change the type to custom and set at least 2 cores and 2 GB of ram.
57+
- Add more vCPUs and memory as you prefer, you can edit after creating the instance as well.
5758
- https://cloud.google.com/compute/docs/machine-types#general_purpose
58-
7. We highly recommend switching the persistent disk to a SSD of at least 32 GB
59+
7. We highly recommend switching the persistent disk to a SSD of at least 32 GB.
60+
- Click `Change` under `Boot Disk` and change the type to `SSD Persistent Disk` and the size
61+
to `32`.
62+
- You can always grow your disk later.
63+
- The default OS of Debian 10 is fine.
5964
8. Navigate to `Networking -> Network interfaces` and edit the existing interface
60-
to use a static external IP
61-
- Click done to save network interface changes
62-
9. If you do not have a [project wide SSH key](https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys#project-wide), navigate to `Security - > SSH Keys` and add your public key there
65+
to use a static external IP.
66+
- Click done to save network interface changes.
67+
9. If you do not have a [project wide SSH key](https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys#project-wide), navigate to `Security - > SSH Keys` and add your public key there.
6368
10. Click create!
6469

6570
Remember, you can shutdown your server when not in use to lower costs.
@@ -82,10 +87,10 @@ systemctl --user enable --now code-server
8287

8388
## 3. Expose code-server
8489

85-
There are several approaches to operating and exposing code-server.
90+
**Never**, **ever** expose `code-server` directly to the internet without some form of authentication
91+
and encryption as someone can completely takeover your machine with the terminal.
8692

87-
Since you can gain access to a terminal from within code-server, **never**, **ever**
88-
expose it directly to the internet without some form of authentication and encryption!
93+
There are several approaches to securely operating and exposing code-server.
8994

9095
By default, code-server will enable password authentication which will
9196
require you to copy the password from the code-server config file to login. You
@@ -99,17 +104,9 @@ We highly recommend this approach for not requiring any additional setup, you ju
99104
SSH server on your remote machine. The downside is you won't be able to access `code-server`
100105
without an SSH client like an iPad. If that's important to you, skip to [Let's Encrypt](#lets-encrypt).
101106

102-
Recommended reading: https://help.ubuntu.com/community/SSH/OpenSSH/PortForwarding
107+
Recommended reading: https://help.ubuntu.com/community/SSH/OpenSSH/PortForwarding.
103108

104-
```bash
105-
# -N disables executing a remote shell
106-
ssh -N -L 8080:127.0.0.1:8080 <instance-ip>
107-
```
108-
109-
As long as this command hasn't exited, that means any request on local port 8080 goes to your
110-
instance at `127.0.0.1:8080` which is where code-server is running.
111-
112-
Next ssh into your instance and edit your code-server config file to disable password authentication.
109+
First, ssh into your instance and edit your code-server config file to disable password authentication.
113110

114111
```bash
115112
# Replaces "auth: password" with "auth: none" in the code-server config.
@@ -122,6 +119,13 @@ Restart code-server with (assuming you followed the guide):
122119
systemctl --user restart code-server
123120
```
124121

122+
Now forward local port 8080 to `127.0.0.1:8080` on the remote instance.
123+
124+
```bash
125+
# -N disables executing a remote shell
126+
ssh -N -L 8080:127.0.0.1:8080 <instance-ip>
127+
```
128+
125129
Now if you access http://127.0.0.1:8080 locally, you should see code-server!
126130

127131
If you want to make the SSH port forwarding persistent we recommend using
@@ -130,7 +134,7 @@ If you want to make the SSH port forwarding persistent we recommend using
130134
```
131135
# Same as the above SSH command but runs in the background continously.
132136
# Add `mutagen daemon start` to your ~/.bashrc to start the mutagen daemon when you open a shell.
133-
mutagen forward create --help -n=code-server tcp:127.0.0.1:8080 <instance-ip>:tcp:127.0.0.1:8080
137+
mutagen forward create --name=code-server tcp:127.0.0.1:8080 <instance-ip>:tcp:127.0.0.1:8080
134138
```
135139

136140
We also recommend adding the following lines to your `~/.ssh/config` to quickly detect bricked SSH connections:
@@ -149,14 +153,14 @@ and sign commits without copying your keys onto the instance.
149153

150154
### Let's Encrypt
151155

152-
Let's Encrypt is a great option if you want to access code-server on an iPad or just want password
153-
based authentication. This does require that the remote machine is exposed to the internet.
156+
[Let's Encrypt](https://letsencrypt.org) is a great option if you want to access code-server on an iPad
157+
or do not want to use SSH forwarding. This does require that the remote machine is exposed to the internet.
154158

155159
Assuming you have been following the guide, edit your instance and checkmark the allow HTTP/HTTPS traffic options.
156160

157-
1. You'll need to buy a domain name. We recommend [Google Domains](https://domains.google.com)
158-
2. Add an A record to your domain with your instance's IP
159-
3. Install caddy https://caddyserver.com/docs/download#debian-ubuntu-raspbian
161+
1. You'll need to buy a domain name. We recommend [Google Domains](https://domains.google.com).
162+
2. Add an A record to your domain with your instance's IP.
163+
3. Install caddy https://caddyserver.com/docs/download#debian-ubuntu-raspbian.
160164

161165
```bash
162166
echo "deb [trusted=yes] https://apt.fury.io/caddy/ /" \
@@ -189,11 +193,15 @@ the dependency on caddy.
189193
**note:** Self signed certificates do not work with iPad and will cause a blank page. You'll
190194
have to use [Let's Encrypt](#lets-encrypt) instead.
191195

192-
Recommended reading: https://security.stackexchange.com/a/8112
196+
Recommended reading: https://security.stackexchange.com/a/8112.
193197

194198
We recommend this as a last resort as self signed certificates do not work with iPads and can
195199
cause other bizarre issues. Not to mention all the warnings when you access code-server.
196-
Only use this if you do not want to buy a domain or cannot expose the remote machine to the internet.
200+
Only use this if:
201+
202+
1. You do not want to buy a domain.
203+
2. You cannot expose the remote machine to the internet.
204+
3. You do not want to use SSH forwarding.
197205

198206
ssh into your instance and edit your code-server config file to use a randomly generated self signed certificate:
199207

@@ -217,8 +225,8 @@ Edit your instance and checkmark the allow HTTPS traffic option.
217225
Visit `https://<your-instance-ip>` to access code-server.
218226
You'll get a warning when accessing but if you click through you should be good.
219227

220-
You can also use [mkcert](https://mkcert.dev) to create a self signed certificate trusted by your
221-
OS to avoid the warnings and then pass it to code-server via the `cert` and `cert-key` config
228+
To avoid the warnings, you can use [mkcert](https://mkcert.dev) to create a self signed certificate
229+
trusted by your OS and then pass it into code-server via the `cert` and `cert-key` config
222230
fields.
223231

224232
### Change the password?
@@ -234,4 +242,4 @@ systemctl --user restart code-server
234242

235243
If you're working on a web service and want to access it locally, code-server can proxy it for you.
236244

237-
See the [FAQ](https://github.com/cdr/code-server/blob/master/doc/FAQ.md#how-do-i-securely-access-web-services).
245+
See [FAQ.md](https://github.com/cdr/code-server/blob/master/doc/FAQ.md#how-do-i-securely-access-web-services).

0 commit comments

Comments
 (0)