- Products
- Learn
- Local User Groups
- Partners
- More
Welcome to Maestro Masters!
Talk to Masters, Engage with Masters, Be a Maestro Master!
Join our TechTalk: Malware 2021 to Present Day
Building a Preventative Cyber Program
Be a CloudMate!
Check out our cloud security exclusive space!
Check Point's Cyber Park is Now Open
Let the Games Begin!
As YOU DESERVE THE BEST SECURITY
Upgrade to our latest GA Jumbo
CheckFlix!
All Videos In One Space
I do not see the password sent to sftp auth in the script.
When I ran the script, it doesn't read from the log_files_to_transfer.txt. My example below uses a SSH key for authentication to the remote host. Without the ssh key, then there's no method for authentication with SFTP.
#!/bin/bash
#Find log files inside the /var/log directory that are at least three months old and store those files in a #text file.
find $FWDIR/log/ -name "2021*" -type f -mtime +5 2> /dev/null > log_files_to_transfer.txt
#Send all of the files found to the remote log server via sftp.
for file in `cat log_files_to_transfer.txt`
do
echo put $file | sftp -b- -i /home/admin/.ssh/SSHKEY <user>@<ip>:<directory>
done
If you're running it from a cronjob, then the script won't understand the $FWDIR environment variable and it will need to be sourced first. This can be added above your first find statement.
source /tmp/.CPprofile.sh
I didn't test the log removal section of your script. I would consider using the built-in log storage management functionality that can be found in SmartConsole rather than scripting the removal of log files. The copy script can be referenced to run before log deletion.
About CheckMates
Learn Check Point
Advanced Learning
YOU DESERVE THE BEST SECURITY