FortiGate
FortiGate Next Generation Firewall utilizes purpose-built security processors and threat intelligence security services from FortiGuard labs to deliver top-rated protection and high performance, including encrypted traffic.
rishab444
Staff
Staff
Article Id 372970
Description

This article describes how to remove all previous FortiToken references from the users through a script which is essentially helpful in case of RMA when Tokens need to be moved to a new device.

Scope FortiGate
Solution
  1. Open CLI on FortiGate and access the user list using Fortitoken:

    config user local
    show | grep -f fortitoken

  2. Copy all the users listed and paste it on Notepad++. The users can be local or remote:

    new doc.PNG

     

  3. On Notepad++, Access Search -> Replace or Press 'CTRL + H ' and select 'Regular expressions' Search Mode as below:

    RG.png

      

  4. Replace <set two-factor> with <unset two-factor> as:

    repftk.png

     

Result:


replaced.PNG

  1. Replace all other lines with a space, leaving the 'Replace with' field empty using the below Regular expressions in the 'Find What' field.

Regular Expression:

 

set fortitoken "FTKMOB[A-Za-z0-9]{<No. of characters following  FTKMOB>}"

 

Example:

 

set fortitoken "FTKMOB[A-Za-z0-9]{10}"


FTKRG.PNG

 

After Replacement:

res.PNG

 

Regular Expression:

 

set email-to "([^"]*)"


emres.PNG

 

Regular Expression:

 

set passwd-time.*$


pwdtm.PNG

 

Regular Expression:

 

set passwd.*$


pwd.PNG

 

  1. Remove all the empty lines using the below Regular Expression:

 

^\s*\r?\n


New Lines.PNG

 

  1. Remove 'show | grep -f fortitoken' and copy the remaining resulting script and run on the CLI. This will keep the users intact and just disable the FortiToken assigned to each user. The users can now be reassigned the FortiTokens as per the availability and requirements.