> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nscale.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Security groups

> Manage security groups for controlling network access to instances.

Security groups act as virtual firewalls, controlling inbound and outbound traffic for compute instances.

**Aliases:** `security-groups`, `sg`, `securitygroups`

Commands that act on one security group take its ID or name either as a positional argument or with `--id`. If you omit it, the CLI opens an interactive picker, so always pass it in scripts.

## Subcommands

* [list](#list) — List security groups
* [get](#get) — Get security group details
* [create](#create) — Create a new security group
* [update](#update) — Update an existing security group
* [delete](#delete) — Delete a security group

***

## list

List security groups, optionally filtered by organization, project, network, or region.

```bash theme={null}
nscale security-groups list [flags]
```

**Aliases:** `list`, `ls`

### Flags

<table>
  <thead><tr><th>Flag</th><th>Description</th></tr></thead>

  <tbody>
    <tr><td>`--org string`</td><td>Organization ID or name</td></tr>
    <tr><td>`--project string`</td><td>Project ID or name</td></tr>
    <tr><td>`--network string`</td><td>Network ID or name</td></tr>
    <tr><td>`--region string`</td><td>Region ID or name</td></tr>

    <tr>
      <td>
        `--limit int`
      </td>

      <td>Show at most N results (client-side; every result is still fetched). Cuts before `-q`. `0` for all</td>
    </tr>

    <tr>
      <td>
        `--json`
      </td>

      <td>Emit the full JSON payload (mutually exclusive with `-q`)</td>
    </tr>

    <tr>
      <td>
        `-q, --query stringArray`
      </td>

      <td>jq filter for value extraction (see [Query output with `-q`](https://docs.nscale.com/docs/cli/query-output))</td>
    </tr>
  </tbody>
</table>

### Example

```bash theme={null}
nscale security-groups list --network <network-id>
nscale security-groups list -q '.[].metadata.id' -q '.[].metadata.name'
```

***

## get

Get details for a specific security group.

```bash theme={null}
nscale security-groups get <sg-id>
```

### Flags

<table>
  <thead><tr><th>Flag</th><th>Description</th></tr></thead>

  <tbody>
    <tr><td>`--id string`</td><td>Security group ID or name</td></tr>
    <tr><td>`--org string`</td><td>Organization ID or name</td></tr>

    <tr>
      <td>
        `--json`
      </td>

      <td>Emit the full JSON payload (mutually exclusive with `-q`)</td>
    </tr>

    <tr>
      <td>
        `-q, --query stringArray`
      </td>

      <td>jq filter for value extraction (see [Query output with `-q`](https://docs.nscale.com/docs/cli/query-output))</td>
    </tr>
  </tbody>
</table>

***

## create

Create a new security group. Accepts input from a JSON file or stdin; with neither, the CLI prompts for the security group details and rules.

```bash theme={null}
nscale security-groups create [flags]
```

### Flags

<table>
  <thead><tr><th>Flag</th><th>Description</th></tr></thead>

  <tbody>
    <tr><td>`--org string`</td><td>Organization ID or name</td></tr>
    <tr><td>`-f, --file string`</td><td>Path to a JSON file</td></tr>
    <tr><td>`--stdin`</td><td>Read JSON from standard input</td></tr>
    <tr><td>`--dry-run`</td><td>Preview actions and payload without persisting</td></tr>
    <tr><td>`-y, --yes`</td><td>Automatically confirm creation</td></tr>

    <tr>
      <td>
        `--json`
      </td>

      <td>Emit the full JSON payload (mutually exclusive with `-q`)</td>
    </tr>

    <tr>
      <td>
        `-q, --query stringArray`
      </td>

      <td>jq filter for value extraction (see [Query output with `-q`](https://docs.nscale.com/docs/cli/query-output))</td>
    </tr>
  </tbody>
</table>

### Examples

```bash theme={null}
nscale security-groups create --file securitygroup.json
nscale security-groups create --stdin < securitygroup.json
cat securitygroup.json | nscale security-groups create --stdin
```

***

## update

Update an existing security group. Accepts input from a JSON file or stdin; with neither, the CLI prompts for each field, pre-filled from the security group as it stands.

```bash theme={null}
nscale security-groups update <sg-id> [flags]
```

### Flags

<table>
  <thead><tr><th>Flag</th><th>Description</th></tr></thead>

  <tbody>
    <tr><td>`--id string`</td><td>Security group ID or name</td></tr>
    <tr><td>`--org string`</td><td>Organization ID or name</td></tr>
    <tr><td>`-f, --file string`</td><td>Path to a JSON file</td></tr>
    <tr><td>`--stdin`</td><td>Read JSON from standard input</td></tr>
    <tr><td>`--dry-run`</td><td>Preview actions and payload without persisting</td></tr>
    <tr><td>`-y, --yes`</td><td>Automatically confirm update</td></tr>

    <tr>
      <td>
        `--json`
      </td>

      <td>Emit the full JSON payload (mutually exclusive with `-q`)</td>
    </tr>

    <tr>
      <td>
        `-q, --query stringArray`
      </td>

      <td>jq filter for value extraction (see [Query output with `-q`](https://docs.nscale.com/docs/cli/query-output))</td>
    </tr>
  </tbody>
</table>

### Examples

```bash theme={null}
nscale security-groups update <sg-id> --file securitygroup.json
nscale security-groups update <sg-id> --stdin < securitygroup.json
cat securitygroup.json | nscale security-groups update <sg-id> --stdin
```

***

## delete

Delete an existing security group.

```bash theme={null}
nscale security-groups delete <sg-id> [flags]
```

**Aliases:** `delete`, `rm`, `remove`

### Flags

| Flag | Description |
| - | - |
| `--id string` | Security group ID or name |
| `--org string` | Organization ID or name |
| `--dry-run` | Preview actions and payload without persisting |
| `-y, --yes` | Automatically confirm deletion |

### Example

```bash theme={null}
nscale security-groups delete <sg-id> --yes
```

***

## Related

> [card] [Instances (Console)](https://docs.nscale.com/docs/compute/create-new-instances.md)
>
> Security groups are configured during instance creation.

> [card] [Load balancers (CLI)](https://docs.nscale.com/docs/cli/load-balancers.md)
>
> Load balancers expose services on a network; restrict listener sources with allowed CIDRs.
