This guide explains how to use the compiled standalone executables (.exe, Linux binary, macOS binary) with credential management.
The standalone executables support multiple ways to provide credentials:
The executable looks for .env files in these locations (in order):
- Current directory:
./env - Next to executable:
/path/to/executable/.env - User config directory:
~/.tgmanager/.env - System-wide:
/etc/tgmanager/.env(Linux/macOS)
Create ~/.tgmanager/.env:
mkdir -p ~/.tgmanager
cat > ~/.tgmanager/.env << EOF
# Account credentials
NITEWALKER_API_ID=123456
NITEWALKER_API_HASH=your_api_hash_here
NITEWALKER_PHONE=+1234567890
NITEWALKER_PASSWORD=your_password_here
# Settings
SESSION_DIR=~/.tgmanager/sessions
UPLOAD_DIR=~/uploads
LOG_LEVEL=info
EOFSet credentials as system environment variables:
export NITEWALKER_API_ID=123456
export NITEWALKER_API_HASH=your_api_hash
export NITEWALKER_PHONE=+1234567890
export NITEWALKER_PASSWORD=your_password
./tgmanager-linux -a nitewalker -c upload -i @channel -f file.mp4set NITEWALKER_API_ID=123456
set NITEWALKER_API_HASH=your_api_hash
set NITEWALKER_PHONE=+1234567890
set NITEWALKER_PASSWORD=your_password
tgmanager.exe -a nitewalker -c upload -i @channel -f file.mp4Specify a custom .env file location:
TGMANAGER_CONFIG=/path/to/my/config.env ./tgmanager-linux -a myaccount -c upload -i @channel -f file.mp4When using standalone executables, the recommended directory structure is:
~/.tgmanager/
├── .env # Your credentials
├── sessions/ # Telegram session files
└── uploads/ # Default upload directory
-
File Permissions: Protect your
.envfile:chmod 600 ~/.tgmanager/.env -
Don't Share Executables: Never share executables that might have embedded credentials
-
Use User Directory: Store configs in your home directory, not next to the executable
-
Avoid Current Directory: Don't leave
.envfiles in random directories
# Using config from ~/.tgmanager/.env
./tgmanager-linux -a myaccount -c upload -i @mychannel -f video.mp4# Using specific config file
TGMANAGER_CONFIG=/secure/location/.env ./tgmanager-linux -a account2 -c upload -i @channel -f file.pdf# Place .env next to executable for portable setup
cp ~/.tgmanager/.env /path/to/usb/
cp tgmanager-linux /path/to/usb/
cd /path/to/usb
./tgmanager-linux -a myaccount -c create -n "New Channel"If you see "No accounts configured", check:
- Your
.envfile exists in one of the expected locations - The file has correct permissions (readable by your user)
- Environment variable names match the expected format
The executable will log where it loaded the config from:
[2024-01-01 12:00:00] [info]: Configuration loaded from: /home/user/.tgmanager/.env
By default, standalone executables use:
- Development:
./sessions(in project directory) - Standalone:
~/.tgmanager/sessions(in home directory)
You can override this with SESSION_DIR in your .env file.
If you previously used accounts.js, migrate to .env:
- Create
~/.tgmanager/.envwith your credentials - Delete old
accounts.js - Use the same account names in commands
The standalone executables are now more secure and flexible, supporting multiple configuration methods without embedding credentials.