Skip to main content
Marit
Staff
Staff
July 15, 2026

Technical Tip: Collecting FortiGate diagnostic output using non-interactive SSH

  • July 15, 2026
  • 0 replies
  • 80 views

Description

This article describes how to collect FortiGate diagnostic output using non-interactive SSH.

Scope

FortiGate.

Solution

When there is a requirement to collect a large number of FortiGate sessions (for example, more than 500,000 sessions), retrieving the information through an interactive SSH session can take approximately 10 minutes (based on lab testing using a FortiGate 901G). However, there are several drawbacks to collecting the data this way:

  • The delay occurs because the FortiGate must continuously output the results to the terminal.

  • The process becomes time-consuming when the session information needs to be collected multiple times.

  • Some SSH clients have limitations on the amount of text output they can handle efficiently.


To overcome these limitations, the following example demonstrates how to pass multiple FortiGate commands to SSH without maintaining an interactive remote session and redirect the output directly to a file.
This can be done on Windows, Mac, or Linux:

From Windows command prompt or Mac/Linux terminal:

ssh admin@10.47.20.43 << 'EOF' > output.txt
config global
    get sys status
    diagnose sys session list
exit
EOF


The output from both 'get system status' and 'diagnose sys session list' is saved to output.txt on the local computer.

Thought Leadership Security Summit. Outpace New Threats with AI - enhanced defense. Tuesday, Septmeber 15, 8:30 AM - 2:30 PM PT. The Golf Club at Newcastle, WA.
Fortinet Flag the Hack. Wednesday, August 26, 9:00 AM - 5:00 PM ET, COSM, Atlanta, GA.
Virtual event | September 2026. SASE summit. The age of autonomous trust. Register here!