@lethevimlet/sshift 0.3.0 → 0.3.1
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 +7 -5
- package/package.json +1 -2
- package/src/server/index.js +49 -45
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ npm install -g @lethevimlet/sshift
|
|
|
35
35
|
sshift
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
The application will be available at `
|
|
38
|
+
The application will be available at `https://localhost:8022`
|
|
39
39
|
|
|
40
40
|
## 📖 Documentation
|
|
41
41
|
|
|
@@ -69,10 +69,12 @@ Invoke-Expression (Invoke-WebRequest -Uri "https://raw.githubusercontent.com/let
|
|
|
69
69
|
> **Note:** The Windows installer requires PowerShell to be run as Administrator for npm global installations.
|
|
70
70
|
|
|
71
71
|
The installer will:
|
|
72
|
-
- Install Node.js
|
|
73
|
-
- Install sshift globally
|
|
74
|
-
-
|
|
75
|
-
-
|
|
72
|
+
- Install Node.js 20+ if not present
|
|
73
|
+
- Install sshift globally via npm
|
|
74
|
+
- Start sshift after installation
|
|
75
|
+
- Configure autostart (optional, systemd on Linux, launchd on macOS, Task Scheduler on Windows)
|
|
76
|
+
- Create config at `~/.local/share/sshift/.env/config.json` with HTTPS enabled
|
|
77
|
+
- Print summary with HTTPS access links
|
|
76
78
|
|
|
77
79
|
### Docker
|
|
78
80
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lethevimlet/sshift",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Web-based SSH + SFTP terminal client with tabs and bookmarks",
|
|
5
5
|
"main": "src/server/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
"dotenv": "^17.4.0",
|
|
25
25
|
"express": "^4.18.2",
|
|
26
26
|
"lucide": "^1.7.0",
|
|
27
|
-
"pem": "^1.14.8",
|
|
28
27
|
"selfsigned": "^5.5.0",
|
|
29
28
|
"socket.io": "^4.7.2",
|
|
30
29
|
"ssh2": "^1.15.0",
|
package/src/server/index.js
CHANGED
|
@@ -15,7 +15,6 @@ const https = require('https');
|
|
|
15
15
|
const path = require('path');
|
|
16
16
|
const socketIO = require('socket.io');
|
|
17
17
|
const selfsigned = require('selfsigned');
|
|
18
|
-
const pem = require('pem');
|
|
19
18
|
|
|
20
19
|
// Import utilities
|
|
21
20
|
const { ensureConfig, loadConfig, getPort, getBindAddress, getEnableHttps } = require('./utils/config');
|
|
@@ -27,55 +26,60 @@ const { sshManager, sftpManager } = require('./services');
|
|
|
27
26
|
const { rest, ws } = require('./endpoints');
|
|
28
27
|
|
|
29
28
|
/**
|
|
30
|
-
* Generate self-signed SSL certificates in memory using
|
|
29
|
+
* Generate self-signed SSL certificates in memory using selfsigned package (pure JS, no OpenSSL dependency)
|
|
31
30
|
* @returns {Promise<Object>} Certificate and private key
|
|
32
31
|
*/
|
|
33
|
-
function generateSelfSignedCert() {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
localIPs.push(addr.address);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
// Get hostname
|
|
53
|
-
const hostname = os.hostname();
|
|
54
|
-
|
|
55
|
-
console.log('[HTTPS] Certificate will be valid for:', localIPs.join(', '), 'and hostname:', hostname);
|
|
56
|
-
|
|
57
|
-
// Build alt names array
|
|
58
|
-
const altNames = ['localhost', hostname || 'localhost', ...localIPs];
|
|
59
|
-
|
|
60
|
-
pem.createCertificate({
|
|
61
|
-
days: 365,
|
|
62
|
-
selfSigned: true,
|
|
63
|
-
commonName: hostname || 'localhost',
|
|
64
|
-
altNames: altNames
|
|
65
|
-
}, (err, keys) => {
|
|
66
|
-
if (err) {
|
|
67
|
-
console.error('[HTTPS] Error generating certificate:', err);
|
|
68
|
-
reject(err);
|
|
69
|
-
return;
|
|
32
|
+
async function generateSelfSignedCert() {
|
|
33
|
+
console.log('[HTTPS] Generating self-signed certificate...');
|
|
34
|
+
|
|
35
|
+
const os = require('os');
|
|
36
|
+
|
|
37
|
+
// Get local IP addresses for SAN
|
|
38
|
+
const interfaces = os.networkInterfaces();
|
|
39
|
+
const localIPs = ['127.0.0.1'];
|
|
40
|
+
|
|
41
|
+
// Extract all IPv4 addresses from network interfaces
|
|
42
|
+
Object.values(interfaces).forEach(iface => {
|
|
43
|
+
iface.forEach(addr => {
|
|
44
|
+
if (addr.family === 'IPv4' && !addr.internal) {
|
|
45
|
+
localIPs.push(addr.address);
|
|
70
46
|
}
|
|
71
|
-
|
|
72
|
-
console.log('[HTTPS] Self-signed certificate generated successfully');
|
|
73
|
-
resolve({
|
|
74
|
-
cert: keys.certificate,
|
|
75
|
-
key: keys.serviceKey
|
|
76
|
-
});
|
|
77
47
|
});
|
|
78
48
|
});
|
|
49
|
+
|
|
50
|
+
// Get hostname
|
|
51
|
+
const hostname = os.hostname() || 'localhost';
|
|
52
|
+
|
|
53
|
+
console.log('[HTTPS] Certificate will be valid for:', localIPs.join(', '), 'and hostname:', hostname);
|
|
54
|
+
|
|
55
|
+
// Build Subject Alternative Names
|
|
56
|
+
const altNames = [
|
|
57
|
+
{ type: 2, value: 'localhost' },
|
|
58
|
+
{ type: 2, value: hostname },
|
|
59
|
+
...localIPs.map(ip => ({ type: 7, ip }))
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
try {
|
|
63
|
+
const attrs = [{ name: 'commonName', value: hostname }];
|
|
64
|
+
const pems = await selfsigned.generate(attrs, {
|
|
65
|
+
days: 365,
|
|
66
|
+
keySize: 2048,
|
|
67
|
+
algorithm: 'sha256',
|
|
68
|
+
extensions: [{
|
|
69
|
+
name: 'subjectAltName',
|
|
70
|
+
altNames
|
|
71
|
+
}]
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
console.log('[HTTPS] Self-signed certificate generated successfully');
|
|
75
|
+
return {
|
|
76
|
+
cert: pems.cert,
|
|
77
|
+
key: pems.private
|
|
78
|
+
};
|
|
79
|
+
} catch (err) {
|
|
80
|
+
console.error('[HTTPS] Error generating certificate:', err);
|
|
81
|
+
throw err;
|
|
82
|
+
}
|
|
79
83
|
}
|
|
80
84
|
|
|
81
85
|
// Create Express app
|