Przejdź do treści

UISP – Command Line Interface (CLI)

    Overview

    Readers will learn the format of certain UISP-related CLI commands that can be used on self-hosted UISP installations. 

    NOTES & REQUIREMENTS:

    – Applicable to the latest UISP release version on self-hosted UISP installations.
    – Use the commands listed in this article with caution and only when there is a good reason to do so.
    – The commands listed in this article are intended to be used by network administrators that have knowledge of the Linux CLI.

    Table of Contents

    1. Introduction
    2. Stopping and (re)starting UISP
    3. Set the Superadmin Role
    4. Recovering Passwords and Disabling Two-Factor Authentication (2FA)
    5. Refreshing the Let’s Encrypt Certificate
    6. Reducing the Device Update Frequency
    7. Clearing and Restoring UISP and Device Backup Files
    8. Changing the Processor Worker Count
    9. Whitelisting IP Addresses for the Web UI and API
    10. Related Articles

    Introduction

    ATTENTION: Use the commands listed in this article with caution and only when there is a good reason to do so.

    Below you will find some useful console commands for self-hosted UISP installations. You can use these commands to restart the UISP instance or restoring a backup. Run all the commands listed in this article from a user account that has sudo privileges. Use the –help flag at the end of a command to list the available options.

    Stopping and (re)starting UNM

    Run the command below to restart/rebuild all UISP containers. 

    sudo ~unms/app/unms-cli restart
    

    Click to copy

    Run the command below to stop all UISP containers. 

    sudo ~unms/app/unms-cli stop
    

    Click to copy

    Run the command below to start all UISP containers.

    sudo ~unms/app/unms-cli start
    

    Click to copy

    Set the Superadmin Role

    The Superadmin role is necessary for access to the CRM module. The command below sets the specified user as a super admin.

    sudo ~unms/app/unms-cli set-superadmin --username <username>

    Click to copy

    Running this command without the –username option will list all users that are currently set as super admin:

    sudo ~unms/app/unms-cli set-superadmin

    Click to copy

    Recovering Passwords and Disabling Two-Factor Authentication (2FA)

    ATTENTION: In order for this CLI command to work properly, it is necessary to have docker-compose 1.23.2+ installed. It is possible to check the current docker-compose version with this command:

    sudo docker-compose version

    Click to copy

    In case the docker-compose version is lower than 1.23.2 it is necessary to upgrade it. It is possible to use this command to do it (it may not work if docker-compose was not installed via UISP installation script).

    sudo curl -sL "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    sudo chmod +x /usr/local/bin/docker-compose

    Click to copy

    sudo ~unms/app/unms-cli set-password --username <username>
    

    Click to copy

    The command below will disable two-factor authentication (2FA) for a specific user:

    sudo ~unms/app/unms-cli disable-two-factor --username <username>

    Click to copy

    Running these command without the –username option will list all users:

    sudo ~unms/app/unms-cli set-password
    sudo ~unms/app/unms-cli disable-two-factor

    Click to copy

    Refreshing the Let’s Encrypt Certificate

    This command refreshes the Let’s Encrypt certificate. 

    sudo ~unms/app/unms-cli refresh-certificate
    

    Click to copy

    Reducing the Device Update Frequency

    This command reduces the UISP device update frequency, which is helpful when your UISP instance is overloaded and it is not possible to log into the Web UI. 

    sudo ~unms/app/unms-cli reduce-device-update-frequency

    Click to copy

    Clearing and Restoring UISP and Device Backup Files

    Use the following command to clear the backup files of devices that are connected to the UISP console (server):

    sudo ~unms/app/unms-cli clear-device-backups
    

    Click to copy

    Use the following command to restore the UISP server from a selected backup file.

    sudo ~unms/app/unms-cli restore-backup --file <backup-file>
    

    Click to copy

    NOTE: The most recent/latest automatic backup file is used if you do not specify the –file option.

    Changing the Processor Worker Count

    ATTENTION: The <count> value should not be higher than the actual number of available CPU cores. It is possible to set this value to auto in order to let UISP decide how many workers it needs. It is recommended to have at least 0.5 Gb (500Mb) of free RAM available for each worker.

    Set the number of worker processes to the desired value (count) or use auto:

    sudo ~unms/app/unms-cli set-workers <count>
    sudo ~unms/app/unms-cli set-workers auto

    Click to copy

    Whitelisting IP Addresses for the Web UI and API

    The following commands will allow you to block access to the Network module of the UISP and specify a list of IP addresses that are allowed to access the Network module GUI and API.

    Show the current whitelist:

    sudo ~unms/app/unms-cli ip-whitelist --show
    

    Click to copy

    Create a new whitelist:

    sudo ~unms/app/unms-cli ip-whitelist --set "203.0.113.1,198.51.100.0/25,2001:db8:12:34::/64"
    

    Click to copy

    Clear the whitelist to allow access from all addresses:

    sudo ~unms/app/unms-cli ip-whitelist --clear
    Print Friendly, PDF & Email