Technical Tip: Rename FortiGate(s) default admin user via FortiManager
Description
This article describes how to rename FortiGate(s) default admin via the FortiManager script.
Scope
FortiManager.
Solution
- The default admin username in FortiGate is 'admin', which should be changed for better security. [Best Practice] Create another admin account with a super_admin profile in case the renaming default admin gets any issue.
- In FortiManager, it is possible to use Scripts to change the admin username and push multiple FortiGates (administrator usernames cannot be changed in FortiManager GUI).
- Checking the current admin user: Device Manager -> Device & Groups -> Managed FortiGates -> Select the FortiGate -> System -> Administrators (if the Administrators tab is not visible, it can be enabled via 'Feature Visibility').

- Under Device Manager -> Scripts -> Create New, give a name, select 'Device Database', create the below script, and select 'OK' to save:
config system admin
rename admin to <New Username>
end
Note:
In the case of FortiGate(s) with VDOM, need to modify the script:
config global
config system admin
rename admin to <New Username>
end

- To run the script: Select the script -> Run Script:

- Select the FortiGate(s) and select the right arrow:

- Select Run Now:

- Select OK:

- The script will start running:

- Script ran successfully:

- Checking the Administrators under FortiManager -> Device Manager -> Device & Groups -> Managed FortiGates -> Select the FortiGate -> System -> Administrators: the default 'admin' now has been changed to 'optimusprime' (as set in the script).

- Install the config to FortiGate using 'Install Wizard':


- Select Install Preview to see what changes FortiManager is pushing to the FortiGate(s).

Note:
The install preview will show that FortiManager is creating a new admin with the name set in the script (and with the same set of details/config set on the 'admin' account) and deleting the default 'admin'.


- Select Close and then select Install.

- The installation has been successful.
- Confirming the changes in FortiGate: System -> Administrators -> The default 'admin' user is now changed.

Note 1:
Make sure to manually change the 'admin' credentials for FortiGate in FortiManager -> Device Manager -> Device & Groups -> Managed FortiGate -> 'Right-Click a FortiGate -> Edit:

Note 2:
The script can also be run on 'Remote FortiGate Directly (via CLI)'; it will simply rename the user on the FortiGate. This change will then be updated in FortiManager as 'Auto-update' automatically.

Related articles:
Technical Tip: How to delete or rename the default 'admin' user
