-
Notifications
You must be signed in to change notification settings - Fork 157
/
Copy pathfix-ssh.js
47 lines (40 loc) · 1.33 KB
/
fix-ssh.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
var b = require('bonescript');
b.getPlatform(onGetPlatform);
function onGetPlatform(x) {
if(!x.name || !x.serialNumber || !x.version)
err('getPlatform returned ' + JSON.stringify(x));
console.log('Name = ' + x.name);
console.log('S/N = ' + x.serialNumber);
console.log('Version = ' + x.version);
console.log('BoneScript version = ' + x.bonescript);
b.setDate(Date().toString(), onSetDate);
}
function onSetDate(x) {
b.socket.on('shell', onShell);
b.socket.emit('shell', '\n');
b.socket.emit('shell', 'rm /etc/dropbear/dropbear_rsa_host_key\n');
//b.socket.emit('shell', 'systemctl --system daemon-reload\n');
b.socket.emit('shell', 'systemctl stop dropbear.socket\n');
b.socket.emit('shell', '/etc/init.d/dropbear stop\n');
b.socket.emit('shell', '/etc/init.d/dropbear start\n');
//b.socket.emit('shell', 'systemctl status dropbear.socket\n');
b.socket.emit('shell', 'journalctl -f\n');
setTimeout(complete, 10000);
//complete();
}
function onShell(x) {
console.log('shell: ' + x);
//if(x.indexOf('Listening on dropbear.socket') >= 0)
//complete();
}
function complete() {
console.log('***PASS***');
process.exit(0);
}
function err(x) {
console.log('***FAIL*** ' + x);
throw(x);
}
function printJSON(x) {
console.log('x = ' + JSON.stringify(x));
}