Skip to content
This repository was archived by the owner on Oct 20, 2023. It is now read-only.

Commit b94868f

Browse files
authored
[readme]: add note about automatic SSH setup for GH CLI >= 2.13.0
1 parent 052bae7 commit b94868f

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
lines changed

README.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
## Codespaces Network Bridge
22

3-
🧪 *The extension is currently in Preview stage, so some hiccups are expected. Please help us to improve [by submitting feedback](https://github.com/github/gh-net#troubleshooting)!*
3+
🧪 *The extension is currently in the Preview stage, so some hiccups are expected. Please help us to improve [by submitting feedback](https://github.com/github/gh-net#troubleshooting)!*
44

55
<img width="749" alt="image" src="https://user-images.githubusercontent.com/1478800/161617508-b65de564-60f3-46c8-8394-5b28c8ac477b.png">
66

7-
This [GitHub CLI](https://cli.github.com/) extension allows to bridge network between a Codespace and your local machine, so the `Codespace` can reach out to any remote resource that is reachable from your machine. In another words, it uses your local machine as a network `gateway` to get to those resources.
7+
This [GitHub CLI](https://cli.github.com/) extension allows you to bridge the network between a Codespace and your local machine, so the `Codespace` can reach out to any remote resource that is reachable from your machine. In other words, it uses your local machine as a network `gateway` to get to those resources.
88

99
For instance, if you are using a `VPN` client to connect to private enterprise network to access a database or any other remote resources, this extension enables you to use those private resources from within a Codespace.
1010

1111
[About GitHub CLI](https://cli.github.com/).
1212

1313
## Prerequisites
1414

15+
1. This extension depends on the latest features of [GitHub CLI](https://cli.github.com/)(>= v2.8.0). Please make sure [to upgrade it](https://github.com/cli/cli#installation).
1516

16-
1. This extension depends on the latest features of GitHub CLI(>= v2.8.0), please make sure [to upgrade it](https://github.com/cli/cli#installation). If run the `gh codespace select` command opens the codespace selection dialog, you are good to go.
17+
2. The extension relies on `gh codespace ssh` command to establish SSH tunnel to a Codespace. If you use [GitHub CLI >=2.13.0](https://github.com/cli/cli/releases/tag/v2.13.0) the `SSH` config is created automatically for your Codespaces, otherwise refer to [SSH setup](./docs/SSH_SETUP.md) instructions.
1718

18-
2. The extension relies on `gh codespace ssh` command to establish SSH tunnel to a Codespace, hence you need to setup ssh keys if you didn't before. If you can do `sudo gh codespace ssh` (`sudo` is important since kernel might use different identity under non-root user) and connect to a Codespace successfully, - you are good to go. Refer to [Generating a new SSH key and adding it to the ssh-agent](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) for more info. List of known issues and workarounds for them can be found [here](https://github.com/github/gh-net/issues?q=is%3Aissue+is%3Aopen+label%3Aknown-issue).
19-
20-
3. If your codespace uses a non-default image, ensure that both the [GitHub CLI](https://cli.github.com/), `openssh-server` and `sudo` are installed inside the codespace. Some distros need an `ssh` group too. Please see [linux dependencies doc](./docs/LINUX_DEPENDENCIES.md) for per-distro instructions.
19+
3. If your codespace uses a non-default image, ensure that both the [GitHub CLI](https://cli.github.com/), `openssh-server`, and `sudo` are installed inside the codespace. Some distros need an `ssh` group too. Please see [linux dependencies doc](./docs/LINUX_DEPENDENCIES.md) for per-distro instructions.
2120

2221
## Installation
2322

@@ -33,7 +32,7 @@ Linux:
3332
sudo gh extension install github/gh-net
3433
```
3534

36-
The `sudo` is required during extension installation on Linux due to https://github.com/cli/cli/issues/5456. Hopefully it won't be the case in the future.
35+
The `sudo` permissions are required during extension installation on Linux due to https://github.com/cli/cli/issues/5456. Hopefully, it won't be the case in the future.
3736

3837
## Usage
3938

@@ -43,9 +42,10 @@ To start network forwarding from a Codespace to a local machine, run:
4342
sudo gh net start
4443
```
4544

46-
Connection issues? Please see https://github.com/github/gh-net/issues/9 for some common solutions.
45+
Connection issues? Please see https://github.com/github/gh-net/issues/9 and [SSH setup doc](./docs/SSH_SETUP.md) for some of the known solutions.
46+
4747

48-
This will provide codespace selection dialog:
48+
The command will first open a Codespace selection dialog:
4949

5050
<img width="749" alt="image" src="https://user-images.githubusercontent.com/1478800/161616184-4cd42419-6d97-440c-bf26-cb713baa7607.png">
5151

@@ -55,12 +55,11 @@ Select a codespace and press enter. The extension will connect to selected codes
5555

5656
There are two panels in the connected view of the extension:
5757

58-
- Panel on the left (`NAT`) shows the network address translation table for currently opened connections. For stateful protocols(e.g. `TCP`) the records are cleaned up automatically after connection is closed so the records will come and go as connection is established and closed. For stateless protocols (e.g. `UDP` or `ICMP`) or unsuccessful `TCP` connections the records are cleaned up after some time, so those will show up in the list for some time.
59-
- Panel on the right (`DNS`) shows the resolved `DNS` records, as `hostname`, `record` and `time-to-live` (`TTL`) values.
58+
- Panel on the left (`NAT`) shows the network address translation table for currently opened connections. For stateful protocols(e.g. `TCP`) the records are cleaned up automatically after a connection is closed, so the records will come and go as connections are established and teardown. For stateless protocols (e.g. `UDP` or `ICMP`) or unsuccessful `TCP` connections, the records are cleaned up after a delay; hence those may show up in the list for some time.
59+
- Panel on the right (`DNS`) shows the resolved `DNS` records, as `hostname`, `record`, and `time-to-live` (`TTL`) values.
6060

6161
Press `q` or `ctrl + c` to stop the extension.
6262

63-
6463
### CLI Options
6564

6665
- `--gui`: Enable/disable GUI mode. [`true` | `false`] [default: `true`]
@@ -148,7 +147,7 @@ For list of supported network protocols refer to [this doc](./docs/SUPPORTED_NET
148147

149148
- Something is missing? Please create a [✨ feature request](https://github.com/github/gh-net/issues/new?assignees=&labels=enhancement&template=feature_request.md&title=).
150149
- Something is incorrect? Please create a [🐛 bug report](https://github.com/github/gh-net/issues/new?assignees=&labels=bug&template=bug_report.md&title=).
151-
- For list of known issues refer to [👉 this list](https://github.com/github/gh-net/issues?q=is%3Aissue+is%3Aopen+label%3Aknown-issue).
150+
- For known issues, refer to [👉 this list](https://github.com/github/gh-net/issues?q=is%3Aissue+is%3Aopen+label%3Aknown-issue).
152151

153152
## Useful links
154153

docs/SSH_SETUP.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## Setting up SSH to connect to Codespaces
2+
3+
> Note: Starting from [GitHub CLI 2.13.0](https://github.com/cli/cli/releases/tag/v2.13.0) the `SSH` config is created automatically for all your Codespaces. You can skip all instructions in this doc if you use the appropriate CLI version. We recommend upgrading; please see [Installation](https://github.com/cli/cli#installation) section of GitHub CLI for the upgrading steps.
4+
5+
The extension relies on `gh codespace ssh` command to establish `SSH` tunnel to a Codespace; hence you need to set up `SSH` keys if you haven't yet. A good way to test the setap is to do `sudo gh codespace ssh` (`sudo` is vital since kernel might use a different identity under a non-root user). If you can connect to a Codespace successfully, you are all set. Refer to [Generating a new SSH key and adding it to the ssh-agent](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) for more info. A list of known issues and workarounds for them can be found in the [Common issues](#common-issues) section below and in issues marked with the [known-issue label](https://github.com/github/gh-net/issues?q=is%3Aissue+is%3Aopen+label%3Aknown-issue).
6+
7+
Because `sudo` needs to be used to start the `gh-net` extension, the `SSH` config has to go to the default location for the `root` user, which is `/root/.ssh/` on `Linux` machines. However, the `MacOSX` machines can use `~/.ssh/` as the default location even for the `root` user, so no special config treatment is needed for the Mac machines.
8+
9+
10+
### Common issues
11+
12+
- `SSH` key has a passphrase, and it's impossible to enter it when prompted.
13+
14+
Make sure to add the key to the `SSH` agent before you try to connect to a Codespace. Refer to [adding you key to SSH agent](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#adding-your-ssh-key-to-the-ssh-agent) section for step-by-step instructions.
15+
16+
- The `Enter password for user@codespace:` prompt pops up, but no password work.
17+
18+
It means that the correct `SSH` key or/and config were not picked up by `SSH` agent. Please refer to the previous section's solution to resolve this.

0 commit comments

Comments
 (0)