Skip to main content

SSH Keys

iForge uses application-level SSH to implement the Git SSH protocol, independent of the system sshd.

How It Works

ComparisonApplication-level SSH (iForge)Native sshd
ImplementationGo built-in SSH serverSystem sshd process
Key StorageDatabase~/.ssh/authorized_keys
Key ManagementAdd/delete via Web UIManually edit files
Public Key LookupDatabase query for userFile system lookup
PortConfigurable (default 2022)22

Add SSH Key

  1. Generate key pair (if you don't have one yet):
ssh-keygen -t ed25519 -C "your-email@example.com"
  1. Copy public key:
cat ~/.ssh/id_ed25519.pub
  1. 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 to git@host:owner/repo.git
  • When port is not 22: Keep ssh://git@host:port/owner/repo.git format

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:

  1. Change sshd port, iForge uses 22
  2. 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