docs/cli/commands/gateway.mdx
The Infisical gateway provides secure access to private resources using modern TCP-based SSH tunnel architecture with enhanced security and flexible deployment options.
The gateway system uses SSH reverse tunnels over TCP, eliminating firewall complexity and providing excellent performance for enterprise environments.
infisical gateway start <gateway-name> --enroll-method=token --token=<enrollment-token> --domain=<domain>
The gateway name is provided as a positional argument.
<Info> By default, the gateway automatically connects to the relay with the lowest latency. To target a specific relay, use the `--target-relay-name=<relay-name>` flag. </Info>Once started, the gateway component will:
--target-relay-name flag is specified) <ParamField query="Flags">
<Expandable title="properties">
<ParamField query="enroll-method" type="string" required>
Must be `token` when using an enrollment token.
</ParamField>
<ParamField query="token" type="string" required>
The one-time enrollment token from the Infisical UI.
</ParamField>
<ParamField query="domain" type="string" required>
The URL of your Infisical instance.
</ParamField>
</Expandable>
</ParamField>
```bash
infisical gateway start my-gateway --enroll-method=token --token=<enrollment-token> --domain=https://app.infisical.com
```
After enrollment, the gateway saves its credentials locally. You can safely re-run the same command to restart the gateway. It will detect the token has already been used and skip enrollment automatically.
If this flag is omitted, the gateway will automatically connect to a healthy relay with the lowest latency.
```bash
# Example
infisical gateway start my-gateway --target-relay-name=my-relay --enroll-method=token --token=<token> --domain=<domain>
```
**Note:** For Infisical Cloud users using instance relays, the relay infrastructure is already running and managed by Infisical. If using organization relays or self-hosted instance relays, you must first start a relay server. For more information on deploying relays, refer to the [Relay Deployment Guide](/documentation/platform/gateways/relay-deployment).
```bash
# Example
infisical gateway start <gateway-name> --domain=https://app.your-domain.com --enroll-method=token --token=<token>
```
sudo infisical gateway systemd install my-gateway --enroll-method=token --token=<enrollment-token> --domain=<domain>
```bash
# Example
sudo infisical gateway systemd install my-gateway --enroll-method=token --token=<enrollment-token> --domain=<domain>
```
```bash
# Example
sudo infisical gateway systemd install my-gateway --enroll-method=token --token=<token> --domain=<domain>
```
```bash
# Example
sudo infisical gateway systemd install my-gateway --enroll-method=token --token=<token> --domain=https://app.your-domain.com
```
If this flag is omitted, the gateway will automatically connect to a healthy relay with the lowest latency.
```bash
# Example
sudo infisical gateway systemd install my-gateway --target-relay-name=my-relay --enroll-method=token --token=<token> --domain=<domain>
```
**Note:** For Infisical Cloud users using instance relays, the relay infrastructure is already running and managed by Infisical. If using organization relays or self-hosted instance relays, you must first start a relay server. For more information on deploying relays, refer to the [Relay Deployment Guide](/documentation/platform/gateways/relay-deployment).
The systemd service is installed with secure defaults:
/etc/systemd/system/<gateway-name>.service/etc/infisical/gateways/<gateway-name>.confAfter installation, manage the service with standard systemd commands (replace my-gateway with your gateway name):
sudo systemctl start my-gateway # Start the service
sudo systemctl stop my-gateway # Stop the service
sudo systemctl status my-gateway # Check service status
sudo systemctl disable my-gateway # Disable auto-start on boot
sudo infisical gateway systemd uninstall my-gateway
The gateway name is provided as a positional argument.
</Accordion> </AccordionGroup>