Security Hardening
Keeping Private Git Repositories Secure: A KaliLinux.net Hardening Guide
Practical steps to lock down private git repos: MFA, secret scanning with gitleaks, host hardening, and scoped CI tokens, tested in a Kali lab.

Private git repositories hold source code, secrets, and CI credentials. A single leaked token can expose all three. KaliLinux.net covers Kali tooling for defenders, and this piece stays on that side: locking down private repos in a lab you own or administer.
Harden authentication first
Most private repo breaches start with weak credentials, not exotic exploits. Enforce SSH keys or personal access tokens with scoped permissions. Disable password auth for git over HTTPS where possible. On a lab Git server, cek dulu config-nya:
sshd -T | grep -i passwordauth
Expect passwordauthentication no. Kalau hasilnya yes, edit /etc/ssh/sshd_config, set PasswordAuthentication no, lalu systemctl restart ssh. Test di VM terisolasi sebelum nyentuh production.
Require MFA on the hosting platform (GitHub, GitLab, Gitea). GitHub made 2FA mandatory for all code contributors in 2023, a baseline worth mirroring on any self-hosted instance.
Scan for secrets before they land
A private repo is not a vault. Committed secrets persist in history even after deletion. Run a pre-commit scanner. gitleaks and trufflehog work on Kali:
gitleaks detect --source . --verbose
Wire it as a pre-commit hook so credentials never reach the remote. For existing repos, scan full history: gitleaks detect --source . --log-opts="--all". Rotate any hit immediately. History rewriting with git filter-repo removes the blob, but the secret is already burned the moment it hit a remote.
Limit repo access by role. Read-only for most contributors, write for maintainers, admin for a handful. Audit access lists quarterly. Dormant accounts are the quiet risk.
Secure the server and the pipeline
Self-hosted git (GitLab CE, Gitea) needs the same baseline as any service. Patch the OS, restrict the web UI behind a reverse proxy with TLS, and segment the host from production networks. In a Kali lab, nmap the git host to confirm only intended ports answer:
nmap -sV -p- 192.168.56.20
Compare hasilnya sama surface yang kamu harapkan. Anything unexpected, close it. Run lynis audit system for a config review beyond port scanning.
CI runners deserve separate treatment. Treat runner tokens as high-value. Scope them to a single project, set short expiry, and never echo them into logs. A compromised runner token can read every repo the runner can reach. Isolate runners per trust boundary.
Backups matter for integrity, not just recovery. Sign commits (git commit -S) and verify signatures in CI. Tampered history fails the check. Configure git config --global commit.gpgsign true and distribute public keys through a trusted channel.
Penutup
Private repos gagal lewat auth lemah, secret bocor, dan runner yang kelebihan privilege. Fix auth, scan secret, kunci host-nya, scope token-nya. Test tiap perubahan di lab terisolasi. Referensi lengkap soal git security hardening: https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work
Pertanyaan yang sering diajukan
Why is a private git repo still a security risk?
Which tool scans git repos for secrets?
Should I sign commits in a private repo?
Where can I find more Kali-focused hardening guides?
Situs tetap hidup saat diserang, pindah domain dalam menit saat diblokir
Trafik disaring berlapis sebelum menyentuh server. Dua server: kalau satu tumbang, panel otomatis memindahkan ke server kedua.
- Penyaringan berlapis
- 2 server, auto-pindah
- Rp 7,5 jt/bln · 10 domain