Skip to main content

Knowledgebase

Naya VPS Secure kaise Kare? Ubuntu Server ke Pehle 10 Zaroori Kaam Print

  • ufw firewall, fail2ban, ubuntu server setup, vps security, hindi, ssh key, linux vps
  • 0

Seedha jawab: Naya VPS milte hi ye kaam kijiye: (1) system update, (2) naya sudo user, (3) SSH key login, (4) root aur password login band, (5) UFW firewall, (6) Fail2ban, (7) automatic security updates, (8) timezone, (9) swap, aur (10) backup. Isme 20–30 minute lagte hain, aur VPS hackers ke aam hamlon se kaafi surakshit ho jata hai. Ye guide Ubuntu 22.04/24.04 ke liye hai.
Pehle padhiye: SSH settings badalte waqt purana SSH window band mat kijiye. Naye window me login test karne ke baad hi band kijiye, taaki galti ho to wapas theek kar sakein. Lock ho jayein to Client Area ka VNC Console kaam aayega.

1–2: Update aur naya user

1. System update:

apt update && apt upgrade -y

2. Naya user banaiye (har kaam root se karna khatarnak hai). anand ki jagah apna naam likhiye:

adduser anand
usermod -aG sudo anand

Ab ye user sudo lagakar admin wale commands chala sakta hai.

3–4: SSH key aur root login band

3. SSH key banaiye (apne computer par, VPS par nahi):

ssh-keygen -t ed25519

Enter dabate jaiye. Phir key VPS par bhejiye (Mac/Linux):

ssh-copy-id anand@AAPKA_IP

Windows me C:\Users\AapkaNaam\.ssh\id_ed25519.pub ka text copy karke VPS par /home/anand/.ssh/authorized_keys me paste kijiye.

4. Root aur password login band kijiye:

sudo nano /etc/ssh/sshd_config

Ye lines aisi kijiye:

PermitRootLogin no
PasswordAuthentication no

Save kijiye (Ctrl+O, Enter, Ctrl+X) aur restart kijiye:

sudo systemctl restart ssh

Test: naya terminal kholiye aur ssh anand@AAPKA_IP se login kijiye. Bina password ke login ho jaye, tabhi purana window band kijiye.

5: UFW firewall

Sirf zaroori ports kholiye:

sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
sudo ufw status

Port Kis kaam ka
22 SSH login
80 Website (HTTP)
443 Website (HTTPS)

6: Fail2ban

Fail2ban baar-baar galat password daalne wale IP ko apne aap block karta hai:

sudo apt install fail2ban -y
sudo systemctl enable --now fail2ban
sudo fail2ban-client status sshd

7–9: Auto updates, timezone, swap

7. Automatic security updates:

sudo apt install unattended-upgrades -y
sudo dpkg-reconfigure -plow unattended-upgrades

8. India ka timezone (logs aur cron sahi samay par chalein):

sudo timedatectl set-timezone Asia/Kolkata

9. Swap (kam RAM wale VPS ke liye, 1 GB):

sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

Check karne ke liye: free -h

10: Backup

  • Website files aur database ka roz backup lijiye (jaise mysqldump + tar ek cron job se).
  • Backup VPS ke bahar bhi rakhiye: Google Drive, doosra server ya apna computer.
  • Bada badlav karne se pehle hamesha backup lijiye.

Aksar puchhe jane wale sawal (FAQ)

SSH port 22 badalna chahiye?

Port badalne se bots ke hamle kam dikhte hain, lekin asli suraksha SSH key aur Fail2ban se aati hai. Agar port badlein, to pehle UFW me naya port kholiye, warna aap khud lock ho jayenge.

Galti se lock ho gaya to kya kare?

Client Area me VPS ka VNC Console kholiye. Wo network ke bina seedha server ki screen dikhata hai. Wahan se sshd_config theek karke SSH restart kijiye.

Kya AlmaLinux par bhi yahi steps hain?

Steps wahi hain, lekin commands thode alag hain: apt ki jagah dnf, UFW ki jagah firewalld, aur sudo group ki jagah wheel group. Fail2ban EPEL repository se install hota hai.

Surakshit Indian VPS
A2Z Indian VPS ₹259/mo se: full root access, VNC console aur 24/7 Hindi support.
Indian VPS plans →  |  7004208529

Was this answer helpful?

« Back

Need help choosing a plan?

Talk to a real person on call, WhatsApp or email — in Hindi or English.