Reset Password via Debian CLI

harrywong

Joined
Nov 18, 2019
Messages
10
Reaction score
0
I have a requirement to reset the admin password via the Linux command line of my 3cx system. What is the process for doing this on 20.0.6.724 (this was deployed via AWS).

This is required because I'm unable to access the admin account after deploying and importing a backup of an older version into this newer v20 version. After I imported it, the admin account seemed to get locked or disabled. I have no other admin accounts, and accessing the older 3cx system I used for creating this backup is no longer possible.

Without telling me to try importing it again, or telling my to reset it via the email (I've tried multiple times already, it seems the email was never attached to the admin account), how can one reset the password using only what is available via the Debian CLI (I'm accessing it via ssh).
 
There is no way to reset the passwort over cli... You can try to check your backup xml for an system owner account to find out which email was used. Anyway, there is no admin account like on v18.
 
I guess the admin account didn't have on assigned. It must be too old. I guess my only route of fixing this is restoring it in an older version, creating a few other admin accounts with an email attached, and starting from there.

Sounds like a terrible design choice if you ask me, how can they tell someone to manage a system they can't reset the password to via cli? Insane.
 
That is a problem you made by yourself.... There is no way to reset the password over cli because there is no admin account anymore. Its a normal extension with system owner rights. Maybe you should contact your partner to help you out in this situation. There is also no way to install v18 and restore the backup there to fix it this way.
 
What a great, intuitive system. I love 3CX so much.
 
It is, if you follow the manuals...
 
  • Like
Reactions: ArneDery
  • Like
Reactions: harrywong
This let me create an account, but didn't seem to create one with access to the panel, so it threw me into the 3CX web client. I feel like this is very close, any tips or edits for what I have so far would be greatly appreciated. This is the type of solution I was looking for, if it works, I will be very grateful.

I modified it to work on my debian 12 PBX, this is a ps1 script that I execute using powershell 7 as outlined in that post.

ASP.net:
# 3CX Extension Creation Script (Fixed)
$path = "/usr/lib/3cxpbx/3cxpscomcpp2.dll" # Linux
Add-Type -Path $path

$psCfgServerHost = "127.0.0.1"
$psCfgServerPort = 5485
$psCfgServerUser = "cfguser_default"
$psCfgServerPassword = "supersecure" # Password from PhoneSystem.ini
$psApplicationName = "My3CXApp"

try {
    # Initialize connection
    [TCX.Configuration.PhoneSystem]$ps = [TCX.Configuration.PhoneSystem]::Reset($psApplicationName, $psCfgServerHost, $psCfgServerPort, $psCfgServerUser, $psCfgServerPassword)
   
    # Wait for connection
    while ($ps.Connected -eq $false) {
        Write-Host -ForegroundColor Yellow "Waiting for connection..."
        Start-Sleep -Seconds 1
    }
   
    Write-Host -ForegroundColor Green "Connected successfully"
   
    # Get tenant and create extension
    $tenant = $ps.GetTenant()
    if ($tenant -eq $null) {
        throw "Failed to get tenant"
    }
   
    $e = $tenant.CreateExtension()
    if ($e -eq $null) {
        throw "Failed to create extension"
    }
   
    Write-Host -ForegroundColor Green "Extension created successfully"
   
    # Set extension properties
    $e.EmailAddress = "[email protected]" # Specify an email address you have access to
    $e.FirstName = "super"
    $e.LastName = "admin"
    $e.Number = 998 # If not specified, the next free number will be assigned
   
    # Check if GroupMembership exists and has elements
    if ($e.GroupMembership -ne $null -and $e.GroupMembership.Count -gt 0) {
        $e.GroupMembership[0].RoleTag = ''
    } else {
        Write-Host -ForegroundColor Yellow "Warning: GroupMembership not available or empty"
    }
   
    # Set custom properties
    $e.SetProperty("EXT_MC_PHONE_SYSTEM_ADMIN", 1)
    $e.SetProperty("EXT_MC_ACCESS_TYPE", 4)
   
    # Save the extension
    $e.Save()
    Write-Host -ForegroundColor Green "Extension saved successfully"
   
} catch {
    Write-Host -ForegroundColor Red "Error: $($_.Exception.Message)"
    Write-Host -ForegroundColor Red "Full error: $($_.Exception.ToString())"
} finally {
    # Ensure disconnection
    if ($ps -ne $null) {
        $ps.Disconnect()
        Write-Host -ForegroundColor Yellow "Disconnected from 3CX"
    }
}

Is there an API reference somewhere?
 
  • Like
Reactions: harrywong
I think I'm giving up at this point. I will restore the backup via v18 and go through all the steps I guess. Wish it was more obvious that there was a checklist of steps to do before upgrading.

Thanks for trying, all.
 
If you go to upgrade the existing version it does stop and do some checks, and IIRC links to the above FAQ. I don't know specifically what it checks when upgrading to v20 and migrating at the same time, since I have not actually done that.
 
There is a big warning before you upgrade to check everything. especially the system owner... In your case you didnt see that because you just restored a backup from a v18 to a v20. But also in this case this should only work with a system owner in your backup. Did you check your backup for a system owner?
 
Just to add for anyone else dealing with this, we restored our v18 VM, ensured the system owner had a unique email, imported the v18 backup onto a new AWS v20 instance, and reset the admin password using that email. It seems that no passwords are carried over for this system owner account. Weird and painful design choice in my humble opinion.
 
The password is carried over if you set one for the extension from the system owner. This is something to check before your upgrade.
 
This was done, and it did not work after the upgrade. Attempting to login resulted in Password Incorrect with the extension and system owner email.
 
Than it wasnt correct, did you check the login of the system owner before the upgrade?

Ive done this on more than 70 pbx and it worked everytime.
 
  • Haha
Reactions: harrywong
There is nothing funny about it, ill try to help you. But anyway, you will find a solution without me.
 
  • Like
Reactions: paulodagraca

Forum statistics

Threads
111,859
Messages
589,434
Members
164,699
Latest member
CLTedu