Skip to content

Commit 6b4cb37

Browse files
authored
Guide: Debugging with Nebula SSH commands (#119)
1 parent 7ef8045 commit 6b4cb37

File tree

2 files changed

+99
-3
lines changed

2 files changed

+99
-3
lines changed
+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
title: Debugging with Nebula SSH commands
3+
summary:
4+
This guide describes useful commands built into the SSH server accessible over nebula, which can allow debugging
5+
network connectivity for the nebula host.
6+
---
7+
8+
# Debugging with Nebula SSH commands
9+
10+
This guide describes useful commands built into the SSH server accessible over nebula, which can allow debugging network
11+
connectivity for the nebula host.
12+
13+
First generate a new SSH key for the host you want to debug, via `ssh-keygen -t ed25519 -f ssh_host_ed25519_key`. You
14+
can set it to only accessible by `root` via `chown root:root ssh_host_ed25519_key`, which will ensure that regular users
15+
on that host cannot access the private key.
16+
17+
Next configure the [`sshd`](https://nebula.defined.net/docs/config/sshd/) section on the host you want to debug.
18+
19+
Example config:
20+
21+
```yml
22+
sshd:
23+
enabled: true
24+
listen: 127.0.0.1:2222
25+
host_key: /path/to/ssh_host_ed25519_key
26+
authorized_users:
27+
- user: steeeeve
28+
keys:
29+
- '[ssh public key string]'
30+
```
31+
32+
In this case `steeeeve` and `[ssh public key string]` should be the values for the user you want to enable access for
33+
debugging. You must add the correct public ssh key for the users you wish to access the ssh server with. If you don't
34+
already have an SSH key for the host you want to access from, follow this guide by GitHub:
35+
[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).
36+
37+
Set the `listen` property to localhost for local debugging or to your nebula IP to enable access over the nebula overlay
38+
network.
39+
40+
Next, either run `kill SIGHUP <nebula PID>` or restart nebula and ssh via `ssh 127.0.0.1 -p 2222` for example.
41+
42+
Now you can debug your nebula installation, querying things like your hostmap:
43+
44+
```ssh
45+
> list-hostmap
46+
10.128.1.1: [205.133.20.81:4242]
47+
10.128.1.2: [153.231.31.111:4242]
48+
```
49+
50+
You should be able to run `help` once you're logged in.
51+
52+
```ssh
53+
steeeeve@nebula > help
54+
Available commands:
55+
change-remote - Changes the remote address used in the tunnel for the provided vpn ip
56+
close-tunnel - Closes a tunnel for the provided vpn ip
57+
create-tunnel - Creates a tunnel for the provided vpn ip and address
58+
help - prints available commands or help <command> for specific usage info
59+
list-hostmap - List all known previously connected hosts
60+
list-lighthouse-addrmap - List all lighthouse map entries
61+
list-pending-hostmap - List all handshaking hosts
62+
log-format - Gets or sets the current log format
63+
log-level - Gets or sets the current log level
64+
logout - Ends the current session
65+
mutex-profile-fraction - Gets or sets runtime.SetMutexProfileFraction
66+
print-cert - Prints the current certificate being used or the certificate for the provided vpn ip
67+
print-relays - Prints json details about all relay info
68+
print-tunnel - Prints json details about a tunnel for the provided vpn ip
69+
query-lighthouse - Query the lighthouses for the provided vpn ip
70+
reload - Reloads configuration from disk, same as sending HUP to the process
71+
save-heap-profile - Saves a heap profile to the provided path
72+
save-mutex-profile - Saves a mutex profile to the provided path
73+
start-cpu-profile - Starts a cpu profile and write output to the provided file
74+
stop-cpu-profile - Stops a cpu profile and writes output to the previously provided file
75+
version - Prints the currently running version of nebula
76+
```
77+
78+
You can discover additional information about each command by running `help <command>`.
79+
80+
```ssh
81+
> help list-hostmap
82+
list-hostmap - List all known previously connected hosts
83+
-by-index
84+
gets all hosts in the hostmap from the index table
85+
-json
86+
outputs as json with more information
87+
-pretty
88+
pretty prints json, assumes -json
89+
```
90+
91+
## Notes about some commands
92+
93+
`query-lighthouse <some-ip>` will return an empty result set initially if the host is not connected, but it will trigger
94+
a background request to the Lighthouse. Meaning, you need to run it twice to actually get a result.
95+
96+
`change-remote` has only a temporary effect: after a period of time, Nebula will "revert" to its
97+
[preferred remote](https://nebula.defined.net/docs/config/preferred-ranges/#how-nebula-orders-underlay-ip-addresses-it-learns-about)

docs/guides/viewing-nebula-logs/index.mdx

+2-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@ On Intel processors, Homebrew uses `/usr/local` instead of `/opt/homebrew` as a
5757
sudo tail -f /opt/homebrew/var/log/nebula.*
5858
```
5959

60-
Another useful tool for viewing logs is the built-in
61-
[Console.app](<](https://support.apple.com/guide/console/welcome/mac)>). To access the logs, To access the logs, select
62-
`File -> Open` from the menu and then press
60+
Another useful tool for viewing logs is the built-in [Console.app](https://support.apple.com/guide/console/welcome/mac).
61+
To access the logs, To access the logs, select `File -> Open` from the menu and then press
6362

6463
<kbd>Cmd</kbd> + <kbd>Shift</kbd> + <kbd>G</kbd> in the file picker, which will allow you to enter `/opt/homebrew/var/log/nebula.log`
6564
into the textbox.

0 commit comments

Comments
 (0)