π‘ UM Sync
This guide automates MikroTik User Manager group creation and user imports based on existing PPP profiles and secrets. It saves time in ISP environments by keeping User Manager aligned with your PPPoE user database.
info
The script creates User Manager groups for every PPP profile, then imports PPP secrets as User Manager users if they donβt already exist.
Prerequisitesβ
- β MikroTik RouterOS with User Manager installed/enabled
- β PPP profiles and PPP secrets already configured
- β Admin access via Winbox or SSH/Terminal
- β Sufficient storage for User Manager DB
warning
This script will create User Manager users. It does not update existing users. Test on a nonβproduction router first.
Configuration Stepsβ
Option A: Terminal (Recommended)β
-
Create User Manager groups from PPP profiles
:foreach i in=[/ppp/profile find] do={
:local profName [/ppp/profile get $i name]
:if ([:len [/user-manager/user/group/find where name=$profName]] = 0) do={
/user-manager/user/group/add attributes=("Mikrotik-Group:" . $profName) \
inner-auths="ttls-pap,ttls-chap" \
outer-auths="ttls-pap,ttls-chap" \
name=$profName
}
} -
Import PPP secrets as User Manager users
:foreach i in=[/ppp/secret find] do={
:local userName [/ppp/secret get $i name]
:local profileName [/ppp/secret get $i profile]
:local password [/ppp/secret get $i password]
:if (($password != "") and ($profileName != "")) do={
:if ([:len [/user-manager/user/find where name=$userName]] = 0) do={
:do {
/user-manager/user/add \
name=$userName \
password=$password \
group=$profileName
:log info ("[UM-IMPORT] Added user: " . $userName . " (Profile: " . $profileName . ")")
} on-error={
:log warning ("[UM-IMPORT] Failed to add user: " . $userName)
}
} else={
:log info ("[UM-IMPORT] Skipped existing user: " . $userName)
}
} else={
:log warning ("[UM-IMPORT] Skipped invalid user: " . $userName)
}
} -
(Optional) Save script in System β Scripts
/system script add name=um-sync policy=read,write,test source="<paste script>" -
(Optional) Schedule automatic sync
/system scheduler add name=um-sync interval=1d on-event=um-sync
Option B: Winboxβ
- Open System β Scripts β Add
- Name:
um-sync - Policy: check
read,write,test - Paste the full script (both sections)
- Run Script to create groups and users
- Optional: System β Scheduler β Add to run daily
Understanding the Configurationβ
Flow Diagram
[PPP Profiles] -> [UM Groups]
[PPP Secrets] -> [UM Users]
Components Table
| Component | Purpose | Notes |
|---|---|---|
| PPP Profiles | Source of group names | One group per profile |
| PPP Secrets | Source of users | Username + password |
| User Manager | AAA database | Groups + users |
| Scheduler | Automation | Run daily/weekly |
Verificationβ
- Check User Manager groups
/user-manager/user/group print - Check imported users
/user-manager/user print - Check logs
/log print where message~"UM-IMPORT" - Validate sample user login in your PPP setup
Troubleshootingβ
| Issue | Cause | Solution |
|---|---|---|
| Groups not created | User Manager disabled | Enable User Manager package |
| Users not imported | Empty password | Set PPP secret passwords |
| Wrong group assigned | Profile missing | Fix PPP secret profile field |
| Duplicate users | User exists | Script skips existing by design |
| Script errors | Missing policy | Add read,write,test policies |
| Logs empty | Script not run | Execute script manually |
| UM add fails | DB locked | Reboot UM service/router |
| Authentication fails | Wrong inner/outer auth | Use PAP/CHAP as configured |
| Profile renamed | Group mismatch | Re-run script to create group |
| Large imports slow | UM DB size | Run during offβpeak |
| User Manager missing | Package not installed | Install User Manager package |
| Scheduler not running | Disabled task | Enable scheduler entry |
Advanced Optionsβ
- Add a pre-clean step to remove unused UM users
- Sync groups only for selected PPP profiles
- Run on a schedule (hourly/daily)
- Add email/Telegram alerts on sync failure
- Filter out disabled PPP secrets
- Add rate limits per profile in User Manager
- Mirror User Manager DB backups weekly
- Export a CSV report after each sync
- Log to file for audit trails
- Add a dryβrun mode (no changes)
Related Guidesβ
Completionβ
β User Manager is now synchronized with PPP profiles and secrets!
Next steps:
- Schedule the script
- Verify user logins
- Back up User Manager database