There are several ways to prevent SSH brute force attacks:
1. Change the default SSH port: One of the simplest ways to avoid SSH bruteforce attacks is to change the default port from 22 to another port number, as attackers will most likely be searching for the default port.
1. Use strong passwords: Make sure that you or your users use strong passwords that are difficult to guess. A strong password should be at least 8 to 12 characters long and contain a mix of upper and lowercase letters, digits and special characters.
1. Limit login attempts: You can limit the number of login attempts for SSH connections to prevent brute force attacks. You can do this by setting up an automated lockout that increases with each failed login attempt.
1. Enable two-factor authentication: Enabling two-factor authentication adds an extra level of security to SSH logins. This involves a password, along with a second factor from an app or device that you have access to.
1. Use a firewall: Implementing a firewall can filter out SSH connection attempts from all but known IP addresses, so limiting the number of login attempts and making it harder for attackers to get access.
1. Keep your system updated: Always keep your system updated with the latest patches, as these will address known security vulnerabilities that attackers can exploit.
1. Use SSH keys instead of passwords: Using SSH keys rather than passwords is a good way to safeguard against brute force attacks, as it negates the need to send passwords over the internet.