Kings of DEVOPS
10 subscribers
1 file
1 link
🐍 Pythonda songi va tarqalmagan kodlar kanali: @KingsOfPy

⚙️ JavaScriptda so'ngi va tarqalmagan kodlar kanali: @Kings_of_Js

🗄️DevOps uchun eng kerakli va foydali kanal @kingsofdevops

Admin : @Mistrdev
Download Telegram
Serverga faqat ssh key orqali kirishni sozlash:

1. Windowsda ssh keyni yaratish:
ssh-keygen -t ed25519 -C "your_email@example.com"


2. Yaratilgan ssh keyni ko'rish:

CMD da:
type %USERPROFILE%\.ssh\id_ed25519.pub

Powershellda:
Get-Content ~/.ssh/id_ed25519.pub


3. Serverda .ssh papkasini yaratish (agar bo'lmasa)
mkdir -p ~/.ssh
chmod 700 ~/.ssh


4. Public keyni authorized_keys ichiga yozish:
echo "BU_YERGA_PUBLIC_KEY_PASTA" >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys

Yoki qo'lda yozib qo'ysangiz ham bo'ladi:
nano ~/.ssh/authorized_keys


5. SSH serverni faqat key bilan ishlashga sozlash

SSH konfiguratsiyasini ochamiz:
sudo nano /etc/ssh/sshd_config

Quyidagilar ON bo‘lishi shart:
PubkeyAuthentication yes
PasswordAuthentication no


6. SSH servisini qayta ishga tushirish:
sudo systemctl restart ssh



7. Windows’dan ssh orqali key bilan ulanish:

ssh -i ~/.ssh/id_ed25519 topcargo@SERVER_IP


Agar default .ssh kalitlar bo‘lsa, -i shart emas:

ssh topcargo@SERVER_IP
git clone --single-branch --branch <branch-nomi> <repo-url>


o'ziz xohlagan branchdan clone qilib olish komandasi
module.exports = {
apps: [
{
name: "dev-backend",
script: "dist/main.js",

exec_mode: "fork",
instances: 1,

cwd: "/root/CargoSoft/backend/dev",

autorestart: true,
watch: false,
max_memory_restart: "500M",

out_file: "/var/log/pm2/dev-backend-out.log",
error_file: "/var/log/pm2/dev-backend-error.log",
log_date_format: "YYYY-MM-DD HH:mm:ss",

env: {
NODE_ENV: "development",
PORT: 4009
}
},

{
name: "prod-backend",
script: "dist/main.js",
exec_mode: "cluster",
instances: "max",

cwd: "/root/CargoSoft/backend/prod",

autorestart: true,
watch: false,
max_memory_restart: "700M",

out_file: "/var/log/pm2/prod-backend-out.log",
error_file: "/var/log/pm2/prod-backend-error.log",
log_date_format: "YYYY-MM-DD HH:mm:ss",

env: {
NODE_ENV: "production",
PORT: 4000
}
}
]
};

pm2 uchun nestjs ga ecosystem fayli example
apt install -y docker.io
systemctl enable docker
systemctl start docker


docker run -d --restart=always -p 3031:3001 \
-v uptime-kuma:/app/data \
--name uptime-kuma \
louislam/uptime-kuma:1



Server uchun eng kerakli monitoring xizmati Telegramdan notification yuboradi