Trojan Rust

User Management

Managing users via the CLI with SQL backends

The trojan auth CLI provides user management for SQL authentication backends. This requires a SQL database (SQLite, PostgreSQL, or MySQL).

Initialize the Database

Create the database schema:

trojan auth init --database sqlite://users.db

Supported database URLs:

BackendURL Format
SQLitesqlite://path/to/users.db
PostgreSQLpostgres://user:pass@host/dbname
MySQLmysql://user:pass@host/dbname

Add a User

trojan auth add --database sqlite://users.db \
  --password "user-password" \
  --upload-limit 10737418240 \
  --download-limit 107374182400

Options

OptionDescription
--passwordUser password (required)
--upload-limitUpload traffic limit in bytes (0 = unlimited)
--download-limitDownload traffic limit in bytes (0 = unlimited)
--expireAccount expiration timestamp

The password is hashed with SHA-224 and stored as a 56-byte hex string.

List Users

# Table format (default)
trojan auth list --database sqlite://users.db

# JSON format
trojan auth list --database sqlite://users.db --format json

# CSV format
trojan auth list --database sqlite://users.db --format csv

Output includes: password hash, upload/download traffic, limits, expiration, and enabled status.

Update a User

trojan auth update --database sqlite://users.db \
  --password "user-password" \
  --upload-limit 21474836480

Remove a User

trojan auth remove --database sqlite://users.db \
  --password "user-password"

Reset Traffic Counters

trojan auth reset-traffic --database sqlite://users.db \
  --password "user-password"

Resets both upload and download byte counters to zero.

Traffic Limits

Traffic limits are specified in bytes. Common values:

SizeBytes
1 GB1073741824
10 GB10737418240
100 GB107374182400
1 TB1099511627776
Unlimited0

When a user exceeds their traffic limit, authentication is rejected until the counters are reset or the limits are increased.

On this page