The SSH support is not stable and have issues (hung up error message from git cli). Don't use this option for the moment and prefer HTTP.
This implementation provides SSH support for Git operations alongside the existing HTTP server.
- Parallel Server Startup: Both HTTP and SSH servers run concurrently
- Graceful Shutdown: CTRL+C stops both servers cleanly
- Git Protocol Support: Full support for
git clone,git push, andgit pullover SSH - Authentication: Supports both password and public key authentication (demo mode)
- Host Key Management: Automatic SSH host key generation and persistence
Start both HTTP and SSH servers:
./git-server-s3 server \
--ssh.enabled=true \
--ssh.port=2222 \
--ssh.hostkey=./ssh_host_key \
--http.port=8080 \
--logger.level=debug \
--storage.type=local \
--storage.local.path=./repositoriesCreate a config.yaml file:
http:
port: 8080
logs: true
ssh:
enabled: true
port: 2222
hostkey: ./ssh_host_key
logger:
level: debug
pretty: true
storage:
type: local
local:
path: ./repositoriesThen run:
./git-server-s3 server --config config.yamlexport SSH_ENABLED=true
export SSH_PORT=2222
export SSH_HOST_KEY_PATH=./ssh_host_key
export HTTP_PORT=8080
./git-server-s3 serverOnce the server is running, you can use Git over SSH:
git clone ssh://git@localhost:2222/my-repo.gitcd my-repo
git remote set-url origin ssh://git@localhost:2222/my-repo.git
git push origin maingit pull origin mainThe current implementation includes demo authentication handlers:
- Password Authentication: Any username with password "demo" is accepted
- Public Key Authentication: Any valid SSH public key is accepted
- SSH host key is automatically generated on first run
- Key is saved to the specified path (default:
./ssh_host_key) - Key is reused on subsequent starts for client trust
- Uses Ed25519 key type for better security and performance
The servers support graceful shutdown:
- Press
CTRL+Cor sendSIGINT/SIGTERMto stop both servers - Servers complete ongoing requests before shutting down
- 30-second timeout for forced shutdown if needed
All SSH operations are logged with structured logging:
- Connection events
- Authentication attempts
- Git command execution
- Error conditions
Example log output:
2:34PM INF Starting HTTP server port=8080
2:34PM INF Starting SSH server port=2222
2:34PM INF SSH Git server started addr=:2222
^C2:34PM INF Shutdown signal received, stopping servers...
2:34PM INF Shutting down HTTP server
2:34PM INF Shutting down SSH server
2:34PM INF All servers stopped gracefully