Skip to content

Commit 367e3f3

Browse files
committed
Add SSH allowlist policy
1 parent 11e6e60 commit 367e3f3

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

src/content/docs/learning-paths/secure-internet-traffic/build-network-policies/recommended-network-policies.mdx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,60 @@ Allow SSH traffic to specific endpoints on the Internet for specific users. You
254254

255255
Optionally, you can include a selector to filter by source IP or IdP group.
256256

257+
<Tabs syncKey="dashPlusAPI">
258+
259+
<TabItem label="Dashboard">
260+
257261
| Selector | Operator | Value | Logic | Action |
258262
| ----------------- | -------- | ------------------- | ----- | ------ |
259263
| Destination IP | in list | _SSHAllowList_ | Or | Allow |
260264
| SNI | in list | _SSHAllowlistFQDN_ | And | |
261265
| Detected Protocol | is | _SSH_ | And | |
262266
| User Group Names | in | _SSH-Allowed-Users_ | | |
263267

268+
</TabItem>
269+
270+
<TabItem label="API">
271+
272+
```sh
273+
curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules \
274+
--header "Content-Type: application/json" \
275+
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
276+
--data '{
277+
"name": "All-NET-SSH-Internet-Allowlist",
278+
"description": "Allow SSH traffic to specific endpoints on the Internet for specific users",
279+
"precedence": 0,
280+
"enabled": true,
281+
"action": "allow",
282+
"filters": [
283+
"l4"
284+
],
285+
"traffic": "net.dst.ip in $<SSH_IP_ALLOWLIST_UUID> and net.sni.host in $<SSH_FQDN_ALLOWLIST_UUID> and net.detected_protocol == \"ssh\"",
286+
"identity": "any(identity.groups.name[*] in {\"SSH-Allowed-Users\"})"
287+
}'
288+
```
289+
290+
</TabItem>
291+
292+
<TabItem label="Terraform">
293+
294+
```tf
295+
resource "cloudflare_zero_trust_gateway_policy" "all_net_ssh_internet_allowlist" {
296+
account_id = var.account_id
297+
name = "All-NET-SSH-Internet-Allowlist"
298+
description = "Allow SSH traffic to specific endpoints on the Internet for specific users"
299+
precedence = 0
300+
enabled = true
301+
action = "allow"
302+
filters = ["l4"]
303+
traffic = "net.dst.ip in ${"$"}${cloudflare_zero_trust_list.ssh_ip_allowlist.id} and net.sni.host in ${"$"}${cloudflare_zero_trust_list.ssh_fqdn_allowlist.id} and net.detected_protocol == \"ssh\""
304+
identity = "any(identity.groups.name[*] in {\"SSH-Allowed-Users\"})"
305+
}
306+
```
307+
308+
</TabItem>
309+
</Tabs>
310+
264311
## All-NET-NO-HTTP-HTTPS-Internet-Deny
265312

266313
Block all non-web traffic towards the Internet. By using the **Detected Protocol** selector, you will ensure alternative ports for HTTP and HTTPS are allowed.

0 commit comments

Comments
 (0)