Servers and the agent, backend (2.1.0): join, jobs, schedules, port list, stats, alerts
- Agent API /api/agent/v1: join with a one-time token, then poll, stats, report and export upload, all signed with the server's Ed25519 key. - Jobs signed with a separate job key (HUB_JOB_SIGNING_KEY_FILE) when delivered, config sealed to the server; one at a time per server; missed when not picked up in their window. - New install (licence, ports, preflight against the release's env template), Proxy done with public URL checks, scheduled / emergency (2FA, reason) / batch updates with email and banner, uninstall with an encrypted export first (the key is never stored), adopt and linking existing installs, purge after 30 days. - Port list, install defaults, server configuration (encrypted), stats per minute / hour with roll-up, server alerts. contracts 1.3.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,22 +1,25 @@
|
||||
/**
|
||||
* Create the Hub's licence signing key pair (Ed25519).
|
||||
* Create the Hub's signing key pairs (Ed25519).
|
||||
*
|
||||
* npm run generate-keys → keys/hub-signing-key.pem (refuses to overwrite)
|
||||
* npm run generate-keys -- --force → replace it (every install then needs the new public key!)
|
||||
* npm run generate-keys → keys/hub-signing-key.pem: licences (refuses to overwrite)
|
||||
* npm run generate-keys -- --job → keys/hub-job-key.pem: jobs for server agents (2.1.0)
|
||||
* add --force to replace one: every install then needs the new licence key, or every server
|
||||
* must join again for a new job key (agents pin it when they join).
|
||||
*
|
||||
* The private key stays on the Hub server only — back it up somewhere safe. The public key it
|
||||
* prints goes into Cross Events (backend/src/hub/publicKey.js) so installs can check licences.
|
||||
* The private keys stay on the Hub server only — back them up somewhere safe. The two are
|
||||
* separate, so a leaked job key can't sign licences and the other way round.
|
||||
*/
|
||||
|
||||
const crypto = require('crypto');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const job = process.argv.includes('--job');
|
||||
const dir = path.join(__dirname, '..', 'keys');
|
||||
const file = path.join(dir, 'hub-signing-key.pem');
|
||||
const file = path.join(dir, job ? 'hub-job-key.pem' : 'hub-signing-key.pem');
|
||||
|
||||
if (fs.existsSync(file) && !process.argv.includes('--force')) {
|
||||
console.error(`${file} already exists. Use --force to replace it (installs would need the new public key).`);
|
||||
console.error(`${file} already exists. Use --force to replace it (${job ? 'every server would have to join again' : 'installs would need the new public key'}).`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
@@ -25,6 +28,10 @@ fs.mkdirSync(dir, { recursive: true });
|
||||
fs.writeFileSync(file, privateKey.export({ type: 'pkcs8', format: 'pem' }), { mode: 0o600 });
|
||||
|
||||
console.log(`Private key written to ${file} — keep it secret and back it up.`);
|
||||
console.log('Set HUB_SIGNING_KEY_FILE to that path in .env.\n');
|
||||
console.log('Public key (for Cross Events, backend/src/hub/publicKey.js):\n');
|
||||
console.log(publicKey.export({ type: 'spki', format: 'pem' }));
|
||||
if (job) {
|
||||
console.log('Set HUB_JOB_SIGNING_KEY_FILE to that path in .env. Agents receive the public key when they join.');
|
||||
} else {
|
||||
console.log('Set HUB_SIGNING_KEY_FILE to that path in .env.\n');
|
||||
console.log('Public key (for Cross Events, backend/src/hub/publicKey.js):\n');
|
||||
console.log(publicKey.export({ type: 'spki', format: 'pem' }));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user