-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: create ssh jail file to fix and configure fail2ban (#67)
- Loading branch information
1 parent
2595774
commit 6363b7f
Showing
4 changed files
with
114 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package network | ||
|
||
import ( | ||
"fmt" | ||
"github.com/nodetec/rwz/pkg/utils/files" | ||
"github.com/nodetec/rwz/pkg/utils/network" | ||
"github.com/pterm/pterm" | ||
"os" | ||
"os/exec" | ||
) | ||
|
||
// Function to configure the intrusion detection system | ||
func ConfigureIntrusionDetection() { | ||
spinner, _ := pterm.DefaultSpinner.Start("Configuring intrusion detection system...") | ||
|
||
// Check if the SSH jail file exists and remove it if it does | ||
files.RemoveFile(SSHJailFilePath) | ||
|
||
// Create the SSH jail file | ||
spinner.UpdateText("Creating SSH jail file...") | ||
network.CreateJailFile(SSHJailFilePath, SSHJailFileTemplate) | ||
|
||
// Restart the intrusion detection system to apply the changes | ||
err := exec.Command("systemctl", "restart", "fail2ban").Run() | ||
if err != nil { | ||
pterm.Println() | ||
pterm.Error.Println(fmt.Sprintf("Failed to restart intrusion detection system: %v", err)) | ||
os.Exit(1) | ||
} | ||
|
||
spinner.Success("Intrusion detection system configured successfully.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters