This document describes how to securely deploy and use LGH.
LGH binds to 127.0.0.1 by default, meaning only the local machine can access it. When exposing to a network, additional security measures must be taken.
lgh serve # Default 127.0.0.1:9418- β Only accessible from local machine
- β No additional configuration needed
- β No remote access
# 1. Setup authentication
lgh auth setup
# 2. Start server (can bind to network)
lgh serve --bind 0.0.0.0
# 3. Client usage
git clone http://username:[email protected]:9418/repo.gitConfiguration example (~/.localgithub/config.yaml):
port: 9418
bind_address: "0.0.0.0"
read_only: true # Recommended: read-only mode
auth_enabled: true
auth_user: "git-user"
auth_password_hash: "salt:hash..."This is the most secure approach, with LGH still binding to 127.0.0.1 and a mature reverse proxy handling authentication and TLS.
# Caddyfile
git.example.com {
# Automatic HTTPS
basicauth * {
git-user $2a$14$hashhere...
}
reverse_proxy localhost:9418
}# Start LGH (local only)
lgh serve
# Start Caddy
caddy runserver {
listen 443 ssl;
server_name git.example.com;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
auth_basic "Git Access";
auth_basic_user_file /etc/nginx/.htpasswd;
location / {
proxy_pass http://127.0.0.1:9418;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
# Large timeouts needed for Git
proxy_read_timeout 3600;
proxy_send_timeout 3600;
client_max_body_size 0; # Unlimited
}
}Generate htpasswd:
htpasswd -c /etc/nginx/.htpasswd git-user# 1. Install cloudflared
brew install cloudflare/cloudflare/cloudflared
# 2. Create tunnel
cloudflared tunnel create lgh
# 3. Configure Access policy (in Cloudflare dashboard)
# 4. Run tunnel
cloudflared tunnel --url http://localhost:9418# ngrok supports built-in auth
ngrok http 9418 --auth="user:password"- Use strong passwords (at least 12 characters)
- Config file permissions set to 0600
- Consider using read-only mode
- Check firewall rules
- Regularly update LGH
- Monitor access logs
- Rotate passwords periodically
# β Wrong: Direct exposure without auth
lgh serve --bind 0.0.0.0
# β Wrong: Tunnel without auth
ngrok http 9418
# β Wrong: Weak password
lgh auth hash "123456"# β
Correct: Local use
lgh serve
# β
Correct: Network exposure + auth + read-only
lgh auth setup
lgh serve --bind 0.0.0.0 --read-only
# β
Correct: Reverse proxy (best)
lgh serve # Listen only on localhost
caddy run # Handle TLS and auth# ~/.localgithub/config.yaml
port: 9418
bind_address: "127.0.0.1"
read_only: falseport: 9418
bind_address: "0.0.0.0"
read_only: true
auth_enabled: true
auth_user: "team"
auth_password_hash: "your-hash-here"port: 9418
bind_address: "127.0.0.1" # Local only, reverse proxy handles network
read_only: false
# Authentication handled by reverse proxy
auth_enabled: falseLGH uses HMAC-SHA256 with salt for password hashing:
# Generate password hash
lgh auth hash
# Hash format: salt:hash
# Example: a1b2c3d4e5:f6a7b8c9d0e1f2...If you discover a security vulnerability, please email [email protected]. Do not disclose publicly.