🛡️ SSH బ్రూట్ ఫోర్స్ డిఫెన్స్: మీ లైనక్స్ సర్వర్ను పటిష్టం చేయడాని 🛡️ SSH Brute Force Defense: A Step-by-Step Guide to Hardening Your Linux Server

IT professional with 20+ years in infrastructure, security, and cloud. I create bilingual (Telugu-English) tutorials and blogs through Yerravalli IT Simplified, making complex tech clear and practical. Explore my work at
Secure Shell (SSH) is the backbone of remote server management. However, its default exposed state makes it a prime target for automated brute-force attacks, where bots attempt to guess your login credentials.
సెక్యూర్ షెల్ (SSH) అనేది రిమోట్ సర్వర్ నిర్వహణకు వెన్నెముక. అయితే, దాని డిఫాల్ట్ బహిర్గత స్థితి ఆటోమేటెడ్ బ్రూట్-ఫోర్స్ దాడులకు ప్రధాన లక్ష్యంగా మారుతుంది, ఇక్కడ బాట్లు మీ లాగిన్ ఆధారాలను ఊహించడానికి ప్రయత్నిస్తాయి.
Protecting your server isn't difficult—it just requires a few crucial steps. This guide will walk you through the essential techniques to lock down your server and significantly reduce the risk of compromise.
మీ సర్వర్ను రక్షించడం కష్టం కాదు—దీనికి కొన్ని ముఖ్యమైన దశలు మాత్రమే అవసరం. మీ సర్వర్ను సురక్షితం చేయడానికి మరియు రాజీ పడే ప్రమాదాన్ని గణనీయంగా తగ్గించడానికి అవసరమైన పద్ధతులను ఈ గైడ్ మీకు చూపుతుంది.
1. Prerequisites
Before we begin, you'll need:
A Linux server (e.g., Ubuntu, Debian, CentOS, RHEL).
Root or sudo access to the server.
Basic familiarity with the Linux command line and text editors like
nanoorvim.
మనం ప్రారంభించే ముందు, మీకు ఇవి అవసరం:
ఒక లైనక్స్ సర్వర్ (ఉదా. Ubuntu, Debian, CentOS, RHEL).
సర్వర్కు రూట్ లేదా sudo యాక్సెస్.
లైనక్స్ కమాండ్ లైన్ మరియు
nanoలేదాvimవంటి టెక్స్ట్ ఎడిటర్లతో ప్రాథమిక పరిచయం.
2. Step 1: Switch to Key-Based Authentication 🔑
2. దశ 1: కీ-ఆధారిత ప్రమాణీకరణకు మారండి 🔑
The single most effective defense is to disable password logins entirely and rely on SSH Key Pairs. This makes brute-force attacks virtually impossible, as guessing a key is mathematically infeasible.
పాస్వర్డ్ లాగిన్లను పూర్తిగా నిలిపివేసి, SSH కీ జతలపై ఆధారపడటం అత్యంత ప్రభావవంతమైన రక్షణ. కీని ఊహించడం గణితపరంగా అసాధ్యం కాబట్టి, ఇది బ్రూట్-ఫోర్స్ దాడులను ఆచరణాత్మకంగా అసాధ్యం చేస్తుంది.
A. Generate Your Key Pair (On Your Local Machine)
A. మీ కీ జతను రూపొందించండి (మీ స్థానిక యంత్రంలో)
If you don't already have one, generate an ED25519 key pair. This is more secure and faster than RSA.
మీకు ఇప్పటికే లేకపోతే, ED25519 కీ జతను రూపొందించండి. ఇది RSA కంటే సురక్షితమైనది మరియు వేగవంతమైనది.
ssh-keygen -t ed25519
You'll be prompted to save the key. The default locations (
~/.ssh/id_ed25519for the private key and~/.ssh/id_ed25519.pubfor the public key) are usually fine.Set a strong passphrase for your private key.
కీని సేవ్ చేయమని మీరు ప్రాంప్ట్ చేయబడతారు. డిఫాల్ట్ స్థానాలు (ప్రైవేట్ కీ కోసం
~/.ssh/id_ed25519మరియు పబ్లిక్ కీ కోసం~/.ssh/id_ed25519.pub) సాధారణంగా సరిపోతాయి.మీ ప్రైవేట్ కీ కోసం బలమైన పాస్ఫ్రేజ్ను సెట్ చేయండి.

B. Copy the Public Key to the Server
B. పబ్లిక్ కీని సర్వర్కు కాపీ చేయండి
Use ssh-copy-id to easily transfer your public key to your server:.
మీ పబ్లిక్ కీని మీ సర్వర్కు సులభంగా బదిలీ చేయడానికి ssh-copy-id ఉపయోగించండి:
ssh-copy-id -i ~/.ssh/id_ed25519.pub your_username@your_server_ip
You will be asked for your password one last time.
మీరు చివరిసారిగా మీ పాస్వర్డ్ కోసం అడగబడతారు.

C. Test Key-Based Login
C. కీ-ఆధారిత లాగిన్ను పరీక్షించండి
Log out and try to log back in using your key:
లాగ్ అవుట్ చేసి, మీ కీని ఉపయోగించి తిరిగి లాగిన్ చేయడానికి ప్రయత్నించండి:
ssh your_username@your_server_ip
If successful, you should be prompted for your key's passphrase instead of your server password.
విజయవంతమైతే, మీ సర్వర్ పాస్వర్డ్కు బదులుగా మీ కీ యొక్క పాస్ఫ్రేజ్ కోసం మీరు ప్రాంప్ట్ చేయబడతారు.

3. Step 2: Disable Password Authentication
3. దశ 2: పాస్వర్డ్ ప్రమాణీకరణను నిలిపివేయండి
Once you confirm key-based login works, you must disable password logins to close the door on brute-force attackers.
కీ-ఆధారిత లాగిన్ పనిచేస్తుందని మీరు నిర్ధారించిన తర్వాత, బ్రూట్-ఫోర్స్ దాడిదారుల నుండి తలుపు మూసివేయడానికి మీరు పాస్వర్డ్ లాగిన్లను నిలిపివేయాలి.
A. Edit the SSH Configuration File
Open the SSH daemon configuration file, typically located at /etc/ssh/sshd_config.
సాధారణంగా /etc/ssh/sshd_config వద్ద ఉన్న SSH డెమోన్ కాన్ఫిగరేషన్ ఫైల్ను తెరవండి.
sudo nano /etc/ssh/sshd_config
B. Apply Hardening Changes
B. పటిష్టం చేసే మార్పులను వర్తింపజేయండి
Find and modify (or add) the following lines:
కింది పంక్తులను కనుగొని సవరించండి (లేదా జోడించండి):
| Directive | Recommended Setting | Purpose |
PasswordAuthentication | no | Crucial: Disables all password logins. |
PermitRootLogin | no | Prevents direct login as the root user. |
X11Forwarding | no | Disable if you don't use graphical applications over SSH. |
Your changes should look like this:
మీ మార్పులు ఇలా ఉండాలి:
# /etc/ssh/sshd_config
PasswordAuthentication no
PermitRootLogin no
X11Forwarding no"
C. Restart the SSH Service
C. SSH సర్వీస్ను పునఃప్రారంభించండి
Apply the changes by restarting the SSH service:
SSH సర్వీస్ను పునఃప్రారంభించడం ద్వారా మార్పులను వర్తింపజేయండి:
On Debian/Ubuntu:
sudo systemctl restart ssh
On CentOS/RHEL:
sudo systemctl restart sshd
4. Step 3: Change the Default SSH Port 🚪
4. దశ 3: డిఫాల్ట్ SSH పోర్ట్ను మార్చండి 🚪
Brute-force bots typically target the default SSH port, 22. Changing this to a non-standard, high-numbered port (e.g., 2222, 58491) won't stop a determined attacker, but it will eliminate the vast majority of automated scanning noise.
బ్రూట్-ఫోర్స్ బాట్లు సాధారణంగా డిఫాల్ట్ SSH పోర్ట్, 22ని లక్ష్యంగా చేసుకుంటాయి. దీన్ని నాన్-స్టాండర్డ్, అధిక సంఖ్య గల పోర్ట్కు (ఉదా. 2222, 58491) మార్చడం వలన నిర్ణీత దాడిదారు ఆగిపోరు, కానీ ఇది ఆటోమేటెడ్ స్కానింగ్ శబ్దంలో ఎక్కువ భాగాన్ని తొలగిస్తుంది.
A. Edit the SSH Configuration File
A. SSH కాన్ఫిగరేషన్ ఫైల్ను సవరించండి
Open /etc/ssh/sshd_config again:
/etc/ssh/sshd_configను మళ్లీ తెరవండి:
sudo nano /etc/ssh/sshd_config
B. Change the Port
B. పోర్ట్ను మార్చండి
Find the line for Port and change it to a port between 1024 and 65535. For example, we'll use 2222.
Port కోసం పంక్తిని కనుగొని, దానిని 1024 మరియు 65535 మధ్య ఉన్న పోర్ట్కు మార్చండి. ఉదాహరణకు, మనం 2222ను ఉపయోగిస్తాము.
# /etc/ssh/sshd_config
Port 2222

C. Open the New Port in the Firewall
C. ఫైర్వాల్లో కొత్త పోర్ట్ను తెరవండి
You must open the new port in your server's firewall before restarting SSH. Otherwise, you will lock yourself out!
మీరు SSHను పునఃప్రారంభించే ముందు మీ సర్వర్ యొక్క ఫైర్వాల్లో కొత్త పోర్ట్ను తప్పక తెరవాలి. లేకపోతే, మీరు లాక్ అవుట్ అవుతారు!
Using UFW (Ubuntu/Debian):
UFW ఉపయోగించి (Ubuntu/Debian):
sudo ufw allow 2222/tcp
sudo ufw delete allow 22/tcp # Remove old port access
Using firewalld (CentOS/RHEL):
firewalld ఉపయోగించి (CentOS/RHEL):
sudo firewall-cmd --permanent --add-port=2222/tcp
sudo firewall-cmd --reload

D. Restart the SSH Service
D. SSH సర్వీస్ను పునఃప్రారంభించండి
sudo systemctl restart ssh
E. Connecting to the New Port
E. కొత్త పోర్ట్కు కనెక్ట్ చేయడం
From now on, you'll need to specify the port when connecting:
ఇకపై, మీరు కనెక్ట్ చేస్తున్నప్పుడు పోర్ట్ను పేర్కొనాలి:
ssh -p 2222 your_username@your_server_ip
Successfully logged in the server with the customized port (sometimes restart may require)

🔧 4.1 Troubleshooting: SSH Key Authentication Issues
🔧4.1 ట్రబుల్షూటింగ్: ఇతర యంత్రాలలో SSH కీ ప్రమాణీకరణ సమస్యలు
Switching to key-based login is secure, but you might run into connection errors when logging in from a new computer or after copying your key. Here are the most common issues and their fixes.
కీ-ఆధారిత లాగిన్కు మారడం సురక్షితం, కానీ కొత్త కంప్యూటర్ నుండి లాగిన్ అయినప్పుడు లేదా మీ కీని కాపీ చేసిన తర్వాత కనెక్షన్ లోపాలను ఎదుర్కొనే అవకాశం ఉంది. ఇక్కడ సాధారణ సమస్యలు మరియు వాటి పరిష్కారాలు ఉన్నాయి.
A. Permission Denied (Public Key)
A. పర్మిషన్ నిరాకరణ (Permission Denied - Public Key)
The most frequent error is "Permission denied (publickey)." This usually means the server either can't find your key or the local machine's permissions are too open.
అత్యంత తరచుగా వచ్చే లోపం "Permission denied (publickey)." దీని అర్థం సర్వర్ మీ కీని కనుగొనలేకపోయింది లేదా స్థానిక యంత్రం యొక్క అనుమతులు చాలా ఓపెన్గా ఉన్నాయి
On Your Local Machine (The machine you are connecting from):
మీ స్థానిక యంత్రంలో (మీరు కనెక్ట్ చేస్తున్న యంత్రం):
సమస్య: మీ ప్రైవేట్ కీ ఫైల్ (
id_ed25519లేదాid_rsa) తప్పు అనుమతులను కలిగి ఉంది. SSHకి చాలా కఠినమైన, సురక్షితమైన అనుమతులు అవసరం.పరిష్కారం: మీ ప్రైవేట్ కీని మీరు మాత్రమే చదవగలరని నిర్ధారించుకోండి.
Issue: Your private key file (
id_ed25519orid_rsa) has incorrect permissions. SSH requires very strict, secure permissions.Fix: Ensure only you can read the private key.
chmod 400 ~/.ssh/id_ed25519
On the Server (The machine you are connecting to):
సర్వర్లో (మీరు కనెక్ట్ అవుతున్న యంత్రం):
సమస్య: సర్వర్లోని
.sshడైరెక్టరీ లేదాauthorized_keysఫైల్ తప్పు అనుమతులను కలిగి ఉంది.పరిష్కారం: సర్వర్లోని కీ ఫైల్ల కోసం ఈ సురక్షిత అనుమతులను ఉపయోగించండి:
Issue: The
.sshdirectory or theauthorized_keysfile on the server has incorrect permissions.Fix: Use these secure permissions for the key files on the server:
# Secure the .ssh directory chmod 700 ~/.ssh # Secure the authorized_keys file chmod 600 ~/.ssh/authorized_keys
B. Key Agent Issues (Key Not Found)
B. కీ ఏజెంట్ సమస్యలు (Key Agent Issues - Key Not Found)
If you are using a new local machine or are prompted for a password instead of your key's passphrase, the system might not be aware of your key.
Issue: Your key is not loaded into the SSH agent, which manages your keys in memory.
Fix: Manually start the agent and add your key:
మీరు కొత్త స్థానిక యంత్రాన్ని ఉపయోగిస్తున్నట్లయితే లేదా మీ కీ యొక్క పాస్ఫ్రేజ్కు బదులుగా పాస్వర్డ్ కోసం ప్రాంప్ట్ చేయబడినట్లయితే, సిస్టమ్కు మీ కీ గురించి తెలియకపోవచ్చు.
సమస్య: మీ కీ SSH ఏజెంట్లో లోడ్ చేయబడలేదు.
పరిష్కారం: ఏజెంట్ను మాన్యువల్గా ప్రారంభించి, మీ కీని జోడించండి:
# Start the SSH agent
eval "$(ssh-agent -s)"
# Add your key to the agent
ssh-add ~/.ssh/id_ed25519
# You will be prompted for your key's passphrase here.
If you have multiple keys, try running ssh-add -l to see which keys are loaded.
C. Key Mismatch or Identity Not Specified
C. కీ సరిపోలకపోవడం లేదా గుర్తింపు పేర్కొనబడకపోవడం (Key Mismatch or Identity Not Specified)
Sometimes, the SSH client tries to use the wrong key or doesn't know which key to use for a specific server.
కొన్నిసార్లు, SSH క్లయింట్ తప్పు కీని ఉపయోగించడానికి ప్రయత్నిస్తుంది లేదా నిర్దిష్ట సర్వర్ కోసం ఏ కీని ఉపయోగించాలో తెలియదు.
Issue: You are not using the default key name (like
id_ed25519) or you have multiple keys.Fix: Explicitly tell the client which key file to use with the
-iflag:సమస్య: మీరు డిఫాల్ట్ కీ పేరును (ఉదా.
id_ed25519) ఉపయోగించడం లేదు లేదా మీకు బహుళ కీలు ఉన్నాయి.పరిష్కారం: ఏ కీ ఫైల్ను ఉపయోగించాలో
-iఫ్లాగ్తో క్లయింట్కు స్పష్టంగా చెప్పండి:
ssh -i ~/.ssh/my_special_server_key -p 2222 your_username@your_server_ip
(గమనిక: మీరు దశ 3ని అనుసరించినట్లయితే, 2222ని మీ కస్టమ్ పోర్ట్తో భర్తీ చేయండి.)
(Note: Replace 2222 with your custom port if you followed Step 3.)
5. Step 4: Install and Configure Fail2ban 🤖
5. దశ 4: Fail2banను ఇన్స్టాల్ చేసి కాన్ఫిగర్ చేయండి 🤖
Even with key-based authentication, you'll still see bots knocking on your door. Fail2ban is an intrusion prevention software that scans log files (like your SSH logs) for repetitive failed login attempts and dynamically bans the corresponding IP addresses using the firewall.
కీ-ఆధారిత ప్రమాణీకరణతో కూడా, మీ తలుపు తట్టే బాట్లను మీరు చూస్తూనే ఉంటారు. Fail2ban అనేది ఒక చొరబాటు నివారణ సాఫ్ట్వేర్, ఇది పునరావృతమయ్యే విఫలమైన లాగిన్ ప్రయత్నాల కోసం లాగ్ ఫైల్లను (మీ SSH లాగ్ల వంటివి) స్కాన్ చేస్తుంది మరియు ఫైర్వాల్ ఉపయోగించి సంబంధిత IP చిరునామాలను డైనమిక్గా నిషేధిస్తుంది.
A. Installation
A. ఇన్స్టాలేషన్
On Debian/Ubuntu:
sudo apt update
sudo apt install fail2ban
On CentOS/RHEL:
sudo yum install fail2ban
sudo systemctl enable fail2ban
B. Basic Configuration
B. ప్రాథమిక కాన్ఫిగరేషన్
Fail2ban uses configuration files called jails. Do not edit the main configuration file (/etc/fail2ban/jail.conf). Instead, create a copy for your local overrides:
Fail2ban జైల్స్ అని పిలువబడే కాన్ఫిగరేషన్ ఫైల్లను ఉపయోగిస్తుంది. ప్రధాన కాన్ఫిగరేషన్ ఫైల్ (/etc/fail2ban/jail.conf)ను సవరించవద్దు. బదులుగా, మీ స్థానిక ఓవర్రైడ్ల కోసం ఒక కాపీని సృష్టించండి:
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo nano /etc/fail2ban/jail.local
C. Modify Jail Settings
C. జైల్ సెట్టింగ్లను సవరించండి
Under the [DEFAULT] section, check/modify the following:
[DEFAULT] విభాగం కింద, కింది వాటిని తనిఖీ చేయండి/సవరించండి:
| Setting | Default/Example | Purpose |
bantime | 1h (or 3600) | How long an IP is banned (1 hour). |
findtime | 10m (or 600) | Time window for failed attempts (10 minutes). |
maxretry | 5 | Number of failed attempts before a ban. |
D. Enable the SSH Jail
D. SSH జైల్ను ప్రారంభించండి
Find the SSH-specific jail, which is typically called [sshd], and ensure it is enabled.
సాధారణంగా [sshd] అని పిలువబడే SSH-నిర్దిష్ట జైల్ను కనుగొని, అది ప్రారంభించబడిందని నిర్ధారించుకోండి.
[sshd]
enabled = true
port = 2222 # IMPORTANT: Use your custom port!
logpath = %(sshd_log)s
backend = systemd
E. Start and Enable Fail2ban
E. Fail2banను ప్రారంభించి ఎనేబుల్ చేయండి
sudo systemctl start fail2ban
sudo systemctl enable fail2ban
sudo systemctl status fail2ban
To see which IPs are currently banned, use:
ప్రస్తుతం ఏ IPలు నిషేధించబడ్డాయో చూడటానికి, ఉపయోగించండి:
sudo fail2ban-client status sshd
Summary of Hardening Steps
పటిష్టం చేసే దశల సారాంశం
By implementing these four steps, you've created a robust defense:
Eliminated the weakest link: Disabled password authentication.
Secured the front door: Disabled direct root login.
Achieved security through obscurity: Changed the default SSH port.
Automated attack defense: Installed and configured Fail2ban.
ఈ నాలుగు దశలను అమలు చేయడం ద్వారా, మీరు బలమైన రక్షణను సృష్టించారు:
బలహీనమైన లింక్ను తొలగించారు: పాస్వర్డ్ ప్రమాణీకరణను నిలిపివేశారు.
ముందు తలుపును సురక్షితం చేశారు: డైరెక్ట్ రూట్ లాగిన్ను నిలిపివేశారు.
గుప్తత ద్వారా భద్రతను సాధించారు: డిఫాల్ట్ SSH పోర్ట్ను మార్చారు.
ఆటోమేటెడ్ దాడి రక్షణ: Fail2banను ఇన్స్టాల్ చేసి కాన్ఫిగర్ చేశారు.
Your Linux server is now significantly hardened against the most common type of attack: the SSH brute-force bot. Stay secure! 🔒
మీ లైనక్స్ సర్వర్ ఇప్పుడు అత్యంత సాధారణ రకం దాడికి: SSH బ్రూట్-ఫోర్స్ బాట్కు వ్యతిరేకంగా గణనీయంగా పటిష్టం చేయబడింది. సురక్షితంగా ఉండండి! 🔒
✅ SSH Hardening Checklist
[x] Change default SSH port
[x] Disable root login
[x] Use key-based authentication
[x] Restrict access by IP
[x] Install Fail2Ban
[x] Monitor logs regularly
📣 Conclusion
SSH is powerful but vulnerable if left unprotected. By following these steps, you’ll greatly reduce the risk of brute force attacks and improve your server’s security posture.
Telugu: ఈ చర్యలు తీసుకోవడం ద్వారా మీ Linux సర్వర్ను brute force దాడుల నుండి రక్షించవచ్చు. మరిన్ని bilingual tutorials కోసం Y-IT Simplified ని ఫాలో అవ్వండి.
🎥 Watch the Full Video
👉Y-iT Simplified - SSH Hardening Tutorial
🔔 Call-to-Action
💬 Share your questions in the comments.
👍 If you found this useful, follow me here on Blogs.
🎥 Don’t forget to watch the full tutorial on my YouTube channel:
SSH Brute Force Defense: A Step-by-Step Guide to Hardening Your Linux Server
👨💻 About the Author
I’m Rajesh Yerravalli, the creator of Yerravalli IT Simplified.
With over 20 years of experience in IT—covering IT Infrastructure, Linux, Windows, Networking, Servers, Cloud, and Cybersecurity—I’m passionate about breaking down complex technical topics into simple, hands-on tutorials.
📺 Watch tutorials on YouTube: Yerravalli IT Simplified (Y-iT Simplified)
✍️ Read more guides here on Hashnode.




