sshifu-trust 0.6.1 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -0
- package/package.json +1 -1
- package/scripts/install.js +118 -0
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# sshifu-trust
|
|
2
|
+
|
|
3
|
+
Configure SSH servers to trust the sshifu certificate authority.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g sshifu-trust
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
sudo sshifu-trust auth.example.com
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
This will configure your SSH server to trust certificates signed by the sshifu CA at the specified address.
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- 🔐 **CA Trust Configuration** - Automatically configures SSH server to trust the CA
|
|
22
|
+
- 🛠️ **Simple Setup** - One command to configure trust
|
|
23
|
+
- 🔒 **Secure** - Only trusts the specific CA, no other changes
|
|
24
|
+
|
|
25
|
+
## Requirements
|
|
26
|
+
|
|
27
|
+
- Node.js 14.0.0+
|
|
28
|
+
- sudo access on the target SSH server
|
|
29
|
+
- Go binary (will be downloaded automatically on install)
|
|
30
|
+
|
|
31
|
+
## Full Documentation
|
|
32
|
+
|
|
33
|
+
See the complete documentation at [github.com/azophy/sshifu](https://github.com/azophy/sshifu)
|
|
34
|
+
|
|
35
|
+
## License
|
|
36
|
+
|
|
37
|
+
MIT
|
package/package.json
CHANGED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Postinstall script for sshifu-trust
|
|
5
|
+
* Downloads the appropriate binary from GitHub releases
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const https = require('https');
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
const { execSync } = require('child_process');
|
|
12
|
+
|
|
13
|
+
const PACKAGE_NAME = 'sshifu-trust';
|
|
14
|
+
const REPO = 'azophy/sshifu';
|
|
15
|
+
|
|
16
|
+
function getPlatform() {
|
|
17
|
+
const platform = process.platform;
|
|
18
|
+
const arch = process.arch;
|
|
19
|
+
|
|
20
|
+
if (platform === 'linux') {
|
|
21
|
+
if (arch === 'x64') return 'linux-amd64';
|
|
22
|
+
if (arch === 'arm64') return 'linux-arm64';
|
|
23
|
+
if (arch === 'arm') return 'linux-arm';
|
|
24
|
+
}
|
|
25
|
+
if (platform === 'darwin') {
|
|
26
|
+
if (arch === 'x64') return 'darwin-amd64';
|
|
27
|
+
if (arch === 'arm64') return 'darwin-arm64';
|
|
28
|
+
}
|
|
29
|
+
if (platform === 'win32') {
|
|
30
|
+
if (arch === 'x64') return 'windows-amd64';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
throw new Error(`Unsupported platform: ${platform} ${arch}`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function download(url, dest) {
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
const file = fs.createWriteStream(dest);
|
|
39
|
+
https.get(url, (response) => {
|
|
40
|
+
if (response.statusCode === 302 || response.statusCode === 301) {
|
|
41
|
+
download(response.headers.location, dest).then(resolve).catch(reject);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (response.statusCode !== 200) {
|
|
46
|
+
reject(new Error(`Download failed with status ${response.statusCode}`));
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
response.pipe(file);
|
|
51
|
+
file.on('finish', () => {
|
|
52
|
+
file.close();
|
|
53
|
+
resolve();
|
|
54
|
+
});
|
|
55
|
+
}).on('error', reject);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function main() {
|
|
60
|
+
const platform = getPlatform();
|
|
61
|
+
const binDir = path.join(__dirname, '..', 'bin');
|
|
62
|
+
const binName = process.platform === 'win32' ? `${PACKAGE_NAME}.exe` : PACKAGE_NAME;
|
|
63
|
+
const binPath = path.join(binDir, binName);
|
|
64
|
+
|
|
65
|
+
// Ensure bin directory exists
|
|
66
|
+
if (!fs.existsSync(binDir)) {
|
|
67
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Get version from package.json
|
|
71
|
+
const pkgPath = path.join(__dirname, '..', 'package.json');
|
|
72
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
73
|
+
let version = pkg.version;
|
|
74
|
+
|
|
75
|
+
// For dev versions, skip download (use local build)
|
|
76
|
+
if (version.includes('dev')) {
|
|
77
|
+
console.log(`[sshifu-trust] Dev version detected, skipping binary download`);
|
|
78
|
+
console.log(`[sshifu-trust] Build manually with: go build -o bin/${binName} ./cmd/${PACKAGE_NAME}`);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const archiveName = `${PACKAGE_NAME}-${platform}.tar.gz`;
|
|
83
|
+
const archiveUrl = `https://github.com/${REPO}/releases/download/v${version}/${archiveName}`;
|
|
84
|
+
const archivePath = path.join(binDir, archiveName);
|
|
85
|
+
|
|
86
|
+
console.log(`[sshifu-trust] Downloading ${archiveUrl}...`);
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
await download(archiveUrl, archivePath);
|
|
90
|
+
|
|
91
|
+
// Extract the archive
|
|
92
|
+
console.log(`[sshifu-trust] Extracting...`);
|
|
93
|
+
const archiveBinName = `${PACKAGE_NAME}-${platform}${process.platform === 'win32' ? '.exe' : ''}`;
|
|
94
|
+
const extractedPath = path.join(binDir, archiveBinName);
|
|
95
|
+
execSync(`tar -xzf "${archivePath}" -C "${binDir}"`, { stdio: 'ignore' });
|
|
96
|
+
|
|
97
|
+
// Rename to expected name if different
|
|
98
|
+
if (archiveBinName !== binName && fs.existsSync(extractedPath)) {
|
|
99
|
+
fs.renameSync(extractedPath, binPath);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Make executable on Unix
|
|
103
|
+
if (process.platform !== 'win32') {
|
|
104
|
+
fs.chmodSync(binPath, 0o755);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Clean up archive
|
|
108
|
+
fs.unlinkSync(archivePath);
|
|
109
|
+
|
|
110
|
+
console.log(`[sshifu-trust] Binary installed successfully!`);
|
|
111
|
+
} catch (err) {
|
|
112
|
+
console.error(`[sshifu-trust] Installation failed: ${err.message}`);
|
|
113
|
+
console.error(`[sshifu-trust] You can download the binary manually from https://github.com/${REPO}/releases`);
|
|
114
|
+
process.exit(1);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
main();
|