đ TKI Auth Setup Guide
Complete step-by-step installation guide for TKI Auth on Linux systems.
đ Prerequisitesâ
- Linux system (Ubuntu 20.04+ recommended)
- Root or sudo access
- Internet connection
- Basic terminal knowledge
đ§ Step 1: Install Node.js with NVMâ
Install NVM (Node Version Manager)â
# Download and install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
# In lieu of restarting the shell
. "$HOME/.nvm/nvm.sh"
Install Node.jsâ
# Download and install Node.js version 22
nvm install 22
# Verify the Node.js version
node -v
# Should print "v22.16.0"
nvm current
# Should print "v22.16.0"
# Verify npm version
npm -v
# Should print "10.9.2"
If you prefer system-wide installation without NVM:
# Ubuntu/Debian
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejs
# Verify installation
node -v && npm -v
đī¸ Step 2: MongoDB Atlas Setupâ
TKI Auth uses MongoDB Atlas (cloud database) for data storage. You don't need to install MongoDB locally.
Create MongoDB Atlas Accountâ
- Go to MongoDB Atlas
- Create a free account or sign in
- Create a new project (e.g., "TKI Auth")
Create Database Clusterâ
- Click "Build a Database"
- Choose FREE tier (M0 Sandbox)
- Select your preferred region
- Name your cluster (e.g., "tki-auth-cluster")
- Click "Create Cluster"
Configure Database Accessâ
-
Database User:
- Go to "Database Access" in left sidebar
- Click "Add New Database User"
- Choose "Password" authentication
- Username:
tkiauth
- Password: Generate secure password or create custom
- Database User Privileges: "Read and write to any database"
- Click "Add User"
-
Network Access:
- Go to "Network Access" in left sidebar
- Click "Add IP Address"
- Click "Allow Access from Anywhere" (or add your server's IP)
- Click "Confirm"
Get Connection Stringâ
- Go to "Database" in left sidebar
- Click "Connect" on your cluster
- Choose "Connect your application"
- Driver: Node.js, Version: 5.5 or later
- Copy the connection string (looks like):
mongodb+srv://tkiauth:<password>@tki-auth-cluster.xxxxx.mongodb.net/?retryWrites=true&w=majority&appName=tki-auth-cluster
- Replace
<password>
with your actual database user password
Your final connection string should look like:
mongodb+srv://tkiauth:YourSecurePassword123@tki-auth-cluster.abc123.mongodb.net/?retryWrites=true&w=majority&appName=tki-auth-cluster
đĻ Step 3: Install TKI Authâ
Download TKI Authâ
Download the latest version from BuiltByBit.
- Go into your root folder of the VPS with:
cd /root/
-
Place the downloaded File into the root folder
-
Unzip the Folder
-
Now start with installing the Dependencies.
You can place the folder of TKI Auth in a different Folder too. It doesnt have to be root
Install Dependenciesâ
# Navigate to TKI Auth directory
cd DIRECTORY
# Install npm dependencies
npm install
# Install PM2 for process management (optional but recommended)
npm install -g pm2
Replace "DIRECTORY" with the Directory of TKI Auth
âī¸ Step 4: Configure TKI Authâ
The configuration file already exists in the Config
folder. You just need to edit it with your settings.
Basic Configurationâ
Edit Config/config.yml
with your settings:
BasicSettings:
Token: "YOUR_DISCORD_BOT_TOKEN"
GuildID: "YOUR_DISCORD_SERVER_ID"
MongoURI: "mongodb+srv://tkiauth:YourPassword@tki-auth-cluster.abc123.mongodb.net/?retryWrites=true&w=majority&appName=tki-auth-cluster"
ShowStats: true
ApiSettings:
Port: 3090
APIKey: "your-secure-api-key-here"
Ratelimit:
Enabled: true
Max: 100
RequireHWID: true
Presence:
Status: "idle"
Activity:
Enabled: true
Type: "Competing"
Intervall: 5
Texts:
- "{total-products} - Total Products"
- "{total-user} - Total Members"
# Configure roles, logging, and other settings as needed...
Required fields you MUST configure:
Token
: Your Discord bot tokenGuildID
: Your Discord server IDMongoURI
: Your MongoDB Atlas connection stringAPIKey
: Generate a secure API key (32+ characters)
đ Step 5: Discord Bot Setupâ
Create Discord Applicationâ
- Go to Discord Developer Portal
- Click "New Application"
- Name your application (e.g., "TKI Auth Bot")
- Go to "Bot" section
- Click "Add Bot"
- Copy the bot token
- Enable necessary intents:
- Message Content Intent
- Server Members Intent
- Presence Intent
Invite Bot to Serverâ
- Go to "OAuth2" â "URL Generator"
- Select scopes:
bot
- Select bot permissions:
- Send Messages
- Use Slash Commands
- Manage Roles
- Read Message History
- Create Public Threads
- Copy the generated URL and invite bot to your server
To be safe you can just give the bot Adminstrator permission.
Get Discord Server IDâ
- Enable Developer Mode in Discord (User Settings â Advanced â Developer Mode)
- Right-click your server name
- Click "Copy Server ID"
- Use this ID in your
config.yml
asGuildID
đ Step 6: Start TKI Authâ
Test Runâ
# Navigate to TKI Auth directory
cd /root/DIRECTORY
# Start TKI Auth in development mode
node .
Replace "DIRECTORY" with the Directory of TKI Auth
Check the console output for any errors. You should see:
- MongoDB connection successful
- Discord bot logged in
- API server started on port 3090
Production Deployment with PM2â
# Start with PM2
pm2 start index.js --name "tki-auth"
# Save PM2 configuration
pm2 save
# Setup PM2 to start on boot
pm2 startup
# Follow the instructions provided by PM2
# Monitor the application
pm2 status
pm2 logs tki-auth
đ Step 7: Security & Firewallâ
Configure Firewallâ
# Install UFW if not installed
sudo apt install ufw
# Allow SSH (important!)
sudo ufw allow ssh
# Allow TKI Auth API port
sudo ufw allow 3090
# Enable firewall
sudo ufw enable
# Check status
sudo ufw status
SSL/TLS Setup (Recommended)â
# Install Nginx
sudo apt install nginx
# Install Certbot for Let's Encrypt
sudo apt install certbot python3-certbot-nginx
# Create Nginx configuration
sudo nano /etc/nginx/sites-available/tki-auth
server {
listen 80;
server_name your-domain.com;
location /api/ {
proxy_pass http://localhost:3090;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
# Enable site
sudo ln -s /etc/nginx/sites-available/tki-auth /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
# Get SSL certificate
sudo certbot --nginx -d your-domain.com
đ¯ Step 8: Verification & Testingâ
Test MongoDB Connectionâ
The connection will be tested automatically when TKI Auth starts. Check the logs:
# If using PM2
pm2 logs tki-auth
# If using systemd
sudo journalctl -u tki-auth -f
# Look for: "MongoDB connected successfully"
Test TKI Auth APIâ
# Test API endpoint
curl -X POST http://localhost:3090/api/license/auth \
-H "Content-Type: application/json" \
-H "Authorization: your-secure-api-key-here" \
-d '{
"data": {
"product": "TestProduct",
"version": "1.0.0",
"licensekey": "TEST-LICENSE-KEY",
"ip": "127.0.0.1",
"hwid": "test-hwid"
}
}'
Test Discord Botâ
- Go to your Discord server
- Try slash commands:
/product list
,/license create
- The bot should respond (even if no products/licenses exist yet)
- Check bot logs for any errors
đ Step 9: Monitoring & Maintenanceâ
Setup Log Rotationâ
# Create logrotate configuration
sudo nano /etc/logrotate.d/tki-auth
/opt/tki-auth/logs/*.log {
daily
missingok
rotate 30
compress
notifempty
create 644 tki-auth tki-auth
postrotate
systemctl reload tki-auth
endscript
}
Regular Maintenance Tasksâ
# Create maintenance script
nano /opt/tki-auth/maintenance.sh
#!/bin/bash
# Backup configuration
DATE=$(date +%Y%m%d_%H%M%S)
cp /opt/tki-auth/config/config.yml "/opt/backups/config_$DATE.yml"
# Clean old logs
find /opt/tki-auth/logs -name "*.log" -mtime +7 -delete 2>/dev/null || true
# Update TKI Auth (if needed)
# cd /opt/tki-auth && git pull && npm install && pm2 restart tki-auth
echo "Maintenance completed at $(date)"
# Make script executable
chmod +x /opt/tki-auth/maintenance.sh
# Add to crontab for daily execution
crontab -e
# Add line:
# 0 2 * * * /opt/tki-auth/maintenance.sh >> /var/log/tki-auth-maintenance.log 2>&1
â Step 10: Post-Installation Checklistâ
- Node.js and npm installed and working (
node -v
,npm -v
) - MongoDB Atlas cluster created and connection string obtained
- TKI Auth downloaded and dependencies installed (
npm install
) - Configuration file
config/config.yml
properly edited - Discord bot created, invited to server, and bot token added to config
- Discord server ID added to config as
GuildID
- TKI Auth service running and starting on boot
- Firewall configured and API accessible on port 3090
- SSL certificate installed (for production with domain)
- API endpoint tested and working
- Discord bot commands working in your server
- Monitoring and logs set up
đ Troubleshootingâ
Common Issuesâ
MongoDB Connection Failed:
# Check your connection string format
# Verify MongoDB Atlas network access (allow your IP)
# Check database user credentials
# Look at TKI Auth logs for detailed error
pm2 logs tki-auth
TKI Auth Won't Start:
# Check logs for detailed error
pm2 logs tki-auth
# Common issues:
# - Wrong Discord bot token
# - Invalid MongoDB connection string
# - Missing required config fields
# - Port 3090 already in use
# Check Node.js version
node -v
Discord Bot Not Responding:
# Verify bot token is correct
# Check Discord Developer Portal - bot should show online
# Verify bot permissions in Discord server
# Check if bot has required intents enabled
# Look for authentication errors in logs
API Requests Failing:
# Check if TKI Auth is running
pm2 status
# Check firewall settings
sudo ufw status
# Test local connection
curl http://localhost:3090/health
# Verify API key in requests matches config
MongoDB Atlas Issues:
# Common MongoDB Atlas problems:
# - IP not whitelisted (add 0.0.0.0/0 for testing)
# - Wrong password in connection string
# - Database user doesn't have proper permissions
# - Network connectivity issues
npm install / Canvas Compilation Failed (Windows):
This error occurs when native modules like canvas
, node-gyp
, or similar packages fail to compile on Windows systems.
Error Symptoms:
gyp ERR! find Python
- Python not found or not workingcanvas
compilation failednode-pre-gyp
404 errors for prebuilt binariesEPERM: operation not permitted
errors
Solution 1: Install Build Tools
# Install Visual Studio Build Tools
npm install --global windows-build-tools
# Or install Visual Studio Build Tools manually from:
# https://visualstudio.microsoft.com/downloads/
# Alternative: Install with chocolatey
choco install visualstudio2019buildtools
Solution 2: Fix Python Configuration
# Check if Python is installed
python --version
# If Python not found, install Python 3.6+ from python.org
# Make sure to check "Add Python to PATH" during installation
# Configure npm to use correct Python
npm config set python "C:\Python311\python.exe"
# (adjust path to your Python installation)
# Set MSBuild version
npm config set msvs_version 2019
Solution 3: Clean Installation
# Clear npm cache
npm cache clean --force
# Remove node_modules and package-lock.json
rmdir /s node_modules
del package-lock.json
# Try installing with legacy-peer-deps
npm install --legacy-peer-deps
# Or skip canvas compilation
npm install --ignore-scripts
Solution 4: Use Node.js LTS Version
# Canvas might not support the latest Node.js version
# Install Node.js 18 LTS instead of 22
# With nvm-windows:
nvm install 18.20.0
nvm use 18.20.0
npm install
# Or download from nodejs.org
Solution 5: Alternative Approach
# If canvas is causing issues, try installing without it
npm install --ignore-scripts
# Or use Docker for consistent environment
docker run -it node:18-alpine sh
Linux-Specific Canvas Issues:
# Install required system dependencies
sudo apt-get update
sudo apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
# For CentOS/RHEL
sudo yum groupinstall "Development Tools"
sudo yum install cairo-devel pango-devel libjpeg-turbo-devel giflib-devel
# Then try npm install again
npm install
Permission Issues (Windows):
# Run PowerShell/CMD as Administrator
# Or try:
npm install --no-optional
# Fix permission issues
npm cache clean --force
npm config set cache C:\npm-cache --global
đ Congratulations!â
Your TKI Auth system is now installed and ready to use!
Next Steps:
Remember:
- Keep your MongoDB Atlas connection string secure
- Regularly backup your configuration files
- Monitor your system for optimal performance
- Update TKI Auth regularly for security and features