Skip to main content
Matt_B
Staff & Editor
Staff & Editor
March 5, 2025

Technical Tip: Logging FortiGate administrative SSH sessions from Linux/MacOS endpoints

  • March 5, 2025
  • 0 replies
  • 871 views
Description This article provides an example of SSH session logging when using Linux or MacOS to connect to FortiGate.
Scope FortiGate.
Solution
  1. To connect to FortiGate as an SSH server while also logging output to a file, open a Linux or MacOS command line interface such as the 'Terminal' application.


Search Terminal.PNG

  1. Connect to the FortiGate using the 'ssh' command and pipe the output to the 'tee' command:

    ssh -l <administrator name> <FortiGate domain name or IP address> | tee <log file name>

    debian ssh tee.PNG

By default, the tee command will overwrite the filename given. To append instead, use '-a' as below.

ssh -l admin 10.21.8.9 | tee -a ssh_session.log

Once created, the log file is readable using a text editor or the 'cat' command.

 

text editor.PNG

 

For serial console connections, one option is the 'screen' command with 'L' to enable logging. The serial console driver and device must already exist. 

 

fortinet@demo:~$ sudo dmesg | grep tty
[sudo] password for fortinet:
[ 0.194449] printk: legacy console [tty0] enabled
[ 1.282010] 00:00: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
fortinet@demo:~$ screen -L /dev/ttyS0 9600

 

For Windows endpoints, Putty is a commonly used terminal emulator and SSH client application for Windows devices.

It can be used to collect a long-running diagnostic from a Fortinet device when an HTTPS diagnostic is not suitable.

It also supports serial console connections.

 

Related article:

Technical Tip: How to create a log file of a session using PuTTY

    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!