Files
sciagent/scripts/deployment/ENABLE-SSH-INSTRUCTIONS.md
Thinh Lam 688fac73e9
CI/CD / backend (push) Failing after 2m8s
CI/CD / frontend (push) Failing after 1m40s
CI/CD / deploy (push) Has been skipped
sciagent code + Gitea Actions CI/CD
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-30 09:38:30 +07:00

53 lines
2.0 KiB
Markdown

# Hướng dẫn mở SSH trên VPS (1 lần duy nhất)
## Cách dễ nhất — copy script vào RDP
1. **RDP vào VPS:**
- Windows + R → `mstsc`
- Computer: `103.124.94.58:3389`
- User: `Administrator`
- Password: (dùng password đã cung cấp)
2. **Mở PowerShell AS ADMINISTRATOR:**
- Start → gõ "PowerShell" → right-click → **Run as Administrator**
3. **Copy-paste toàn bộ file `scripts/deployment/00-enable-ssh-server.ps1`** vào PowerShell → Enter.
4. **Đợi ~1 phút**, khi thấy `DONE — SSH server ready` là xong.
5. **Báo lại cho dev**, dev sẽ test connection:
```bash
ssh -i ~/.ssh/dyd_vps Administrator@103.124.94.58 hostname
```
## Nếu copy-paste qua RDP clipboard không được
**Option A — Upload file qua RDP mapped drive:**
1. Trong mstsc → More → Local Resources → Drives → check `D:\` (hoặc drive chứa repo)
2. Sau khi RDP, mở File Explorer → `\\tsclient\D\...\scripts\deployment\00-enable-ssh-server.ps1`
3. Right-click file → Run with PowerShell (As Admin)
**Option B — Tải từ Gitea/GitHub (sau khi push):**
```powershell
Invoke-WebRequest -Uri '<raw-url>/scripts/deployment/00-enable-ssh-server.ps1' -OutFile C:\Temp\00-enable-ssh.ps1
powershell -ExecutionPolicy Bypass -File C:\Temp\00-enable-ssh.ps1
```
## Script làm gì?
1. Install OpenSSH Server capability (Windows feature)
2. Start `sshd` service + set auto-start
3. Open firewall port 22
4. Set default SSH shell = PowerShell (chứ không phải cmd)
5. Add public key `dyd-vps-deploy-20260415` vào `administrators_authorized_keys`
6. Fix file permission (chỉ Admin + SYSTEM được đọc)
**Idempotent** — chạy nhiều lần OK, không side effect.
## Security
- Public key đã embed trong script
- Private key nằm trên máy dev (`~/.ssh/dyd_vps`) — KHÔNG rời máy
- Nếu mất private key → chạy lại script sau khi đổi `$PublicKey` với key mới
- Disable SSH sau khi xong deploy: `Stop-Service sshd; Set-Service sshd -StartupType Disabled`