SSH Keys
iForge uses application-level SSH to implement the Git SSH protocol, independent of the system sshd.
How It Works
| Comparison | Application-level SSH (iForge) | Native sshd |
|---|---|---|
| Implementation | Go built-in SSH server | System sshd process |
| Key Storage | Database | ~/.ssh/authorized_keys |
| Key Management | Add/delete via Web UI | Manually edit files |
| Public Key Lookup | Database query for user | File system lookup |
| Port | Configurable (default 2022) | 22 |
Add SSH Key
- Generate key pair (if you don't have one yet):
ssh-keygen -t ed25519 -C "your-email@example.com"
- Copy public key:
cat ~/.ssh/id_ed25519.pub
- Add in iForge:
- Go to "Settings" → "SSH Keys"
- Paste public key, click "Add"
Clone with SSH
Non-standard Port (e.g., 2022)
git clone ssh://git@your-host:2022/owner/repo.git
Standard Port 22 (SCP-like Format)
When the SSH port is configured as 22, the clone URL automatically converts to a concise SCP-like format:
git clone git@your-host:owner/repo.git
Auto Conversion Rules
- When port is 22: Automatically omit
ssh://prefix and port number, convert togit@host:owner/repo.git - When port is not 22: Keep
ssh://git@host:port/owner/repo.gitformat
Port Configuration
Set in .env or docker-compose.yml:
IFORGE_SSH_ENABLED=true
IFORGE_SSH_PORT=2022 # Change to 22 to use standard port and enable SCP-like format
Port Conflict
If sshd (port 22) is already running on the host, iForge SSH cannot use port 22 at the same time. Solutions:
- Change sshd port, iForge uses 22
- Or iForge uses a non-22 port (e.g., 2022)
Custom Clone URL Template
Administrators can customize the SSH clone URL prefix template in "System Settings" → "Repository Settings":
- Template variables:
{host},{port} - Example:
ssh://git@{host}:{port}→ Automatically generate complete clone URL - Automatically converts to SCP-like format when port is 22