For v5.0,build0252 (GA Patch 5)
首先在 Fortigate上面建立一個名為backup的使用者,密碼為YourPassword,權限設定如下:
然後在 Linux 建立 sh 並賦予執行權限和建立排程,檔案內容如下:
(範例中的備份伺服器是使用 tftp)
#!/bin/bash
user="backup"
password="YourPassword"
tftp_ip="YourBackupServerIP"
fg_devices="YourFortigateIP"
date="$(date +"%Y%m%d")"
for fg_device in $fg_devices ; do
expect -c "
set timeout 30
spawn ssh $user@$fg_device
expect \"(yes/no)\" { send \"yes\r\"; exp_continue }
expect \"*password:*\"
set send_slow {1 0.05}
send -s \"$password\r\"
send_user \"$password\r\"
expect \"FG*\"
send -s \"execute backup full-config tftp $fg_device-$date.cfg $tftp_ip\n\"
expect \"FG*\"
send -s \"exit\n\"
interact"
done