Skip to content

Commit 0443471

Browse files
shuuri-labsash-nb
andauthored
update SSH docs for v0.61.0 fine-grained access control (#530)
* update SSH docs for v0.61.0 fine-grained access control --------- Co-authored-by: Ashley Mensah <[email protected]>
1 parent 697d71d commit 0443471

File tree

3 files changed

+169
-75
lines changed

3 files changed

+169
-75
lines changed
252 KB
Loading
275 KB
Loading

src/pages/manage/peers/ssh.mdx

Lines changed: 169 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {Note} from "@/components/mdx";
44

55
NetBird provides SSH access to peers through its built-in SSH server. Unlike traditional SSH setups that require exposing port 22 to the internet, NetBird SSH operates entirely over your private network. You can connect using either the `netbird ssh` command or native OpenSSH clients.
66

7+
NetBird SSH supports fine-grained access control, allowing you to specify which NetBird users can access which local OS users on target machines.
8+
79
<Note>
810
SSH Access is disabled by default and must be enabled both on the target
911
peer and in the NetBird Dashboard.
@@ -19,7 +21,7 @@ Management may automatically ensure the mesh access policy permits 22022 for a p
1921

2022
### Authentication Methods
2123

22-
- **JWT Authentication (default)**: Maps SSH sessions to user identities via your configured Identity Provider (OIDC). Each new session will require completing the OIDC flow to mint the JWT used for SSH authentication (unless JWT caching is enabled, in which case JWT tokens are cached for a configurable duration).
24+
- **JWT Authentication (default)**: Maps SSH sessions to user identities via your configured Identity Provider (OIDC). Each new session will require completing the OIDC flow to mint the JWT used for SSH authentication (unless JWT caching is enabled, in which case JWT tokens are cached for a configurable duration). Combined with fine-grained access control, this allows you to control exactly which authenticated users can access which local OS users on the target machine.
2325
- **Machine Identity (`--disable-ssh-auth`)**: When SSH auth is disabled, SSH access is governed by NetBird network ACLs (machine-level access) rather than per-user JWT identity.
2426

2527
### OpenSSH Integration
@@ -42,11 +44,10 @@ The management server does not edit your host OS firewall or perform OS-level po
4244

4345
To use SSH access through NetBird, you need:
4446

45-
1. **NetBird v0.60.0 or later** on peers that should support native SSH (dev/development versions are treated as supporting native SSH).
47+
1. **NetBird v0.61.0 or later** on all peers using SSH (both clients and servers). For fine-grained access control features, v0.61.0 is required.
4648
2. **SSH enabled on target peer** - the peer must run with `--allow-server-ssh`.
47-
3. **SSH enabled in Dashboard** - SSH access must be enabled for the peer and ServerSSHAllowed set in the peer meta.
48-
4. **Access Control Policy** - an ACL rule allowing TCP port 22 for the peer (management will auto-add 22022 behind the scenes for modern peers).
49-
5. **(Optional)** For JWT authentication: an Identity Provider configured in NetBird.
49+
3. **Access Control Policy** - A `NetBird SSH` policy configured in the dashboard
50+
4. **(Optional)** For JWT authentication: an Identity Provider configured in NetBird.
5051

5152
<Note>
5253
Management distributes NetBird access-policy objects (FirewallRule) - it does
@@ -107,22 +108,12 @@ Create an ACL policy to allow SSH access:
107108
3. Create a new policy:
108109
- **Source**: Select the peers or groups that will connect via SSH
109110
- **Destination**: Select the peers or groups running the SSH server
110-
- **Protocol**: TCP
111-
- **Ports**: 22
112-
- **Action**: Accept
111+
- **Protocol**: Select `NetBird SSH` for SSH-specific policies with fine-grained access control, or use `TCP` with port 22 for basic network-level SSH access
112+
- **Authorized Groups** (when using NetBird SSH protocol): Configure which user groups can access which local OS users on the destination machines
113113
4. Save the policy
114114

115-
### Step 3: Enable SSH in Dashboard
116-
117-
Enable SSH on individual peers:
118-
119-
1. Navigate to the target peer details page
120-
2. Enable SSH access for the peer
121-
3. Save the changes
122-
123115
<p>
124-
<img src="/docs-static/img/manage/peers/ssh/ssh-dashboard.png"
125-
alt="netbird ssh dashboard" className="imagewrapper-big"/>
116+
<img src="/docs-static/img/manage/peers/ssh/ssh-access-policy.png" alt="netbird ssh access policy" className="imagewrapper"/>
126117
</p>
127118

128119
## Using NetBird SSH
@@ -204,13 +195,7 @@ For SSH access directly from your web browser without installing any software, r
204195

205196
By default, NetBird SSH uses JWT-based authentication with the configured Identity Provider. This provides user identity verification instead of machine identity.
206197

207-
<Note>
208-
Currently, SSH access is controlled by ACL policies and the
209-
`--enable-ssh-root` flag. Users connect as either root (if enabled) or
210-
admin-equivalent users on Windows. In the future, NetBird will support more
211-
granular user mapping, allowing OIDC user X to connect to specific local
212-
users (PAM/local) on the target system.
213-
</Note>
198+
NetBird supports fine-grained user mapping, allowing you to specify which OIDC users or groups can connect to which local OS users on the target system. See [Fine-Grained Access Control](#fine-grained-access-control) for details.
214199

215200
<Note type="warning">
216201
**Time synchronization required**: The SSH server's system clock must be
@@ -279,6 +264,75 @@ netbird up --allow-server-ssh --disable-ssh-auth
279264
restrictive.
280265
</Note>
281266

267+
## Fine-Grained Access Control
268+
269+
NetBird SSH allows you to configure granular access control that maps NetBird users to specific local OS users on target machines. This provides precise control over who can access what on your infrastructure.
270+
271+
### How It Works
272+
273+
When you create an SSH policy with the `NetBird SSH` protocol, you can configure **Authorized Groups** that define:
274+
275+
1. **Source User Groups**: Which NetBird user groups are allowed to connect
276+
2. **Local User Mapping**: Which local OS users each group can access on the destination machines
277+
278+
For example, you can configure:
279+
- Members of the "Developers" group can SSH as `developer` or `deploy` users
280+
- Members of the "DBAs" group can SSH as `postgres` user
281+
- Members of the "SysAdmins" group can SSH as `root` user
282+
283+
### Configuring Fine-Grained Access Control
284+
285+
When creating or editing an SSH policy in the Dashboard:
286+
287+
1. Navigate to **Access Control** and click **Create Policy**
288+
2. Select **NetBird SSH** as the protocol
289+
3. Configure the **Source** - select the user groups that will connect via SSH
290+
4. Configure the **Destination** - select the peers or groups running the SSH server
291+
5. Under **SSH Access**, choose the access level:
292+
- **Full Access**: Allow SSH as any local user on the destination machines
293+
- **Limited Access**: Specify which local users each source group can access
294+
6. If you selected **Limited Access**, configure the user mappings:
295+
- For each source group, specify which local OS users they are allowed to SSH as
296+
- Add multiple local users per group as needed (e.g., `ashley`, `root`)
297+
7. Enable the policy and click **Continue**
298+
299+
<p>
300+
<img src="/docs-static/img/manage/peers/ssh/ssh-fine-grained-access-policy.png" alt="netbird ssh fine grained access policy" className="imagewrapper"/>
301+
</p>
302+
303+
**Example configuration:**
304+
305+
| Source Group | Allowed Local Users |
306+
|--------------|---------------------|
307+
| Developers | developer, deploy |
308+
| DBAs | postgres |
309+
| SysAdmins | root, admin |
310+
311+
<Note>
312+
When **Full Access** is selected, users in the source groups can SSH as any local user on the destination machines. Use **Limited Access** to enforce the principle of least privilege.
313+
</Note>
314+
315+
### Authorization Flow
316+
317+
When a user attempts to SSH into a peer:
318+
319+
1. The user authenticates via OIDC to obtain a JWT token
320+
2. The JWT contains the user's identity (user ID from the `sub` claim by default)
321+
3. NetBird checks if the user's ID is in the list of authorized users for this peer
322+
4. NetBird verifies the user is allowed to access the requested local OS user based on the policy's authorized groups configuration
323+
5. If authorized, the SSH session is established as the specified local user
324+
325+
<Note>
326+
Fine-grained access control requires JWT authentication to be enabled (the default). It is not available when using `--disable-ssh-auth`.
327+
</Note>
328+
329+
### Security Considerations
330+
331+
- **Fail-closed**: If no mapping exists for an OS user, access is denied by default
332+
- **User identity verification**: Access decisions are based on the authenticated OIDC user identity
333+
- **Audit trail**: All SSH access attempts are logged with the authenticated user's identity
334+
- **Least privilege**: Configure the minimum necessary local user access for each group
335+
282336
## Advanced Features
283337

284338
### Port Forwarding
@@ -398,12 +452,12 @@ Port forwarding has the following limitations:
398452

399453
### User Mapping
400454

401-
- **Current behavior**: SSH sessions connect as either:
402-
- The `root` user on Linux/Unix (if `--enable-ssh-root` is enabled)
403-
- Administrator-equivalent users on Windows
404-
- The SSH server's service account (if user switching is unavailable)
405-
- **Future enhancement**: Planned support for granular user mapping (OIDC user → specific local user)
406-
- **PAM integration**: Linux/Unix PAM integration is planned for more flexible authentication
455+
NetBird now supports fine-grained user mapping through the `NetBird SSH` protocol and Authorized Groups configuration. See [Fine-Grained Access Control](#fine-grained-access-control) for details.
456+
457+
**Requirements for user switching:**
458+
- The NetBird SSH server must run with root/administrator privileges to switch between local users
459+
- Non-root NetBird installations (e.g., rootless containers) will run all sessions under the NetBird process account
460+
- On Windows, sessions connect as Administrator-equivalent users
407461

408462
### Feature Availability
409463

@@ -420,9 +474,9 @@ Some features require specific flags to be enabled on the SSH server:
420474

421475
SSH access is controlled by multiple layers:
422476

423-
1. **Network ACL policies**: Control which peers can access SSH over the mesh. Management will auto-add the mesh-native endpoint (22022) for a peer when the policy explicitly allows port 22 (or a range containing 22) and the peer advertises native SSH support (NetBird v0.60.0+).
424-
2. **SSH enabled in dashboard**: Per-peer SSH access toggle
425-
3. **JWT authentication** (if enabled): User identity verification via IdP
477+
1. **Network ACL policies**: Control which peers can access SSH with dedicated 'NetBird SSH' protocol policies
478+
2. **JWT authentication** (if enabled): User identity verification via IdP
479+
3. **Fine-grained access control** (when using NetBird SSH protocol): Controls which authenticated users can access which local OS users on the target machine
426480

427481
## Troubleshooting
428482

@@ -444,7 +498,7 @@ SSH access is controlled by multiple layers:
444498

445499
**"Connection timeout"**
446500

447-
- Verify ACL policy allows TCP port 22
501+
- Verify ACL policy allows SSH access
448502
- Check if peers are connected to each other: `netbird status -d`
449503
- Test basic connectivity: `ping <peer-ip>`
450504

@@ -472,75 +526,120 @@ SSH access is controlled by multiple layers:
472526
- Check file system permissions on the target peer
473527
- Verify you're connecting with the correct user
474528

529+
### Fine-Grained Access Control Issues
530+
531+
**"User is not authorized to access this peer"**
532+
533+
- Verify the user's group is included in the SSH policy's source groups
534+
- Check that the policy uses the `NetBird SSH` protocol
535+
- Ensure the user has authenticated via OIDC
536+
537+
**"User is not authorized to login as OS user"**
538+
539+
- Check the Authorized Groups configuration in the SSH policy
540+
- Verify the user's group is mapped to the requested local OS user
541+
- Ensure the local OS user exists on the target machine
542+
543+
**"No authorization mapping for OS user"**
544+
545+
- The requested local OS user is not configured in any Authorized Groups mapping
546+
- Add the local OS user to the appropriate group's allowed users list in the policy
547+
475548
## CLI Reference
476549

477550
For complete CLI command reference, including all SSH-related commands and flags, see the [CLI documentation](/get-started/cli#ssh).
478551

479-
## Migrating from v0.59.x and Earlier
552+
## Version History
480553

481-
<Note>
482-
This section is only relevant if you're upgrading from NetBird v0.59.x or
483-
earlier. New installations can skip this section.
554+
### v0.61.0
555+
556+
Version 0.61.0 introduces fine-grained SSH access control.
557+
558+
<Note type="warning">
559+
**Breaking change**: Management server v0.61.0 will break NetBird SSH for all peers running versions older than v0.61.0. You must update all peers that use SSH to v0.61.0 or later before upgrading the management server/dashboard.
484560
</Note>
485561

486-
### What Changed in v0.60.0
562+
#### New Capabilities
563+
564+
- **NetBird SSH protocol**: New protocol type in policies specifically for SSH access control
565+
- **Fine-grained user mapping**: Map NetBird user groups to specific local OS users
566+
- **Authorized Groups**: Configure which users can access which local accounts per policy
567+
- **Full Access vs Limited Access**: Choose between unrestricted local user access or granular per-group mappings
568+
- **Enhanced security**: Fail-closed authorization model with granular audit trail
569+
570+
#### Breaking Changes
571+
572+
- Peers running versions older than v0.61.0 will lose SSH functionality when the management server is upgraded to v0.61.0
573+
574+
#### Upgrade Steps
575+
576+
1. **Update SSH servers** (peers running `--allow-server-ssh`)
577+
578+
2. **Update SSH clients** (peers using `netbird ssh`)
487579

488-
Version 0.60.0 is a complete rewrite with breaking changes:
580+
3. **Update the management server** to v0.61.0
581+
582+
4. **Update the dashboard** to v0.61.0
583+
584+
5. **Create NetBird SSH policy**:
585+
- Source: SSH client user groups
586+
- Destination: SSH server peers/groups
587+
- Protocol: NetBird SSH
588+
- SSH Access: Full Access or Limited Access
589+
- If Limited Access: configure local user mappings per source group
590+
591+
---
592+
593+
### v0.60.0
594+
595+
Version 0.60.0 is a complete rewrite of NetBird SSH with breaking changes.
596+
597+
<Note>
598+
This section is only relevant if you're upgrading from NetBird v0.59.x or earlier.
599+
</Note>
600+
601+
#### New Capabilities
489602

490-
**New capabilities:**
491603
- OpenSSH client support via automatic proxy configuration
492604
- Windows client and server support
493605
- SFTP subsystem for file transfers
494606
- Local and remote port forwarding (`netbird ssh` only)
495607
- Non-interactive command execution
496608
- Configurable JWT token caching
497609

498-
**Breaking changes:**
610+
#### Breaking Changes
611+
499612
- Server port changed from 44338 to 22 (22022 internally)
500613
- Authentication changed from machine public keys to JWT tokens (user identity)
501614
- Port 22 automatically redirects to 22022 for NetBird traffic
502615
- Old implicit firewall rule removed - explicit ACL policy required for port 22
503616
- Client no longer requires `sudo` for authentication
504617
- **Not backward compatible**: v0.60.0+ clients cannot connect to older servers and vice versa
505618

506-
### Upgrade Steps
619+
#### Upgrade Steps
507620

508621
<Note type="warning">
509-
**Self-hosted deployments:** Update order is important:
510-
1. Management server
511-
2. Dashboard (optional - only if you use browser-based SSH)
512-
3. **SSH servers first** (peers running `--allow-server-ssh`)
513-
4. SSH clients last (peers using `netbird ssh`)
514-
515-
New clients cannot connect to old servers, so update servers before clients.
622+
**Update order is important** - SSH servers must be updated before SSH clients.
516623
</Note>
517624

518-
#### For Self-Hosted Deployments
519-
520625
1. **Update management server** to v0.60.0 or later
521-
- Verify server is running correctly
522-
- Confirm JWKS endpoint is accessible
626+
- Verify server is running correctly
627+
- Confirm JWKS endpoint is accessible
523628

524629
2. **Update dashboard** (optional)
525-
- Only needed if you use the browser-based SSH client
526-
- Maintains browser SSH access during peer migration
630+
- Only needed if you use the browser-based SSH client
527631

528632
3. **Create ACL policy** for port 22:
529-
```
530-
Source: [SSH Client Group/Peers]
531-
Destination: [SSH Server Group/Peers]
532-
Protocol: TCP
533-
Port: 22
534-
Action: Accept
535-
```
633+
- Source: SSH client peers/groups
634+
- Destination: SSH server peers/groups
635+
- Protocol: TCP
636+
- Port: 22
536637

537-
4. **Update SSH servers FIRST** (peers running `--allow-server-ssh`)
538-
- Start with non-critical peers for testing
539-
- Old clients can still connect to updated servers
638+
4. **Update SSH servers first** (peers running `--allow-server-ssh`)
639+
- Start with non-critical peers for testing
540640

541-
5. **Update SSH clients LAST** (peers using `netbird ssh`)
542-
- Updated clients cannot connect to old servers
543-
- This is why servers must be updated first
641+
5. **Update SSH clients last** (peers using `netbird ssh`)
642+
- Updated clients cannot connect to old servers
544643

545644
#### Optional Configuration
546645

@@ -554,11 +653,6 @@ Enable JWT token caching on SSH clients (reduces auth prompts):
554653
netbird up --ssh-jwt-cache-ttl 3600 # 1 hour
555654
```
556655

557-
<Note>
558-
The browser-based SSH client in the dashboard remains compatible with both
559-
old and new peer versions.
560-
</Note>
561-
562656
## Get started
563657
<p float="center">
564658
<Button name="button" className="button-5"

0 commit comments

Comments
 (0)