-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathssh.terminal.ts
More file actions
37 lines (31 loc) · 867 Bytes
/
ssh.terminal.ts
File metadata and controls
37 lines (31 loc) · 867 Bytes
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
import { NodeSSH } from "node-ssh";
const ssh = new NodeSSH()
// TERMINAL CONFIGURATION HERE
let sshConfig = {
host: 'localhost',
port: 4001,
username: 'player',
password: 'kali'
}
const connect = async () => {
console.log("[>]","Connecting to",sshConfig.host+":"+sshConfig.port);
await ssh.connect(sshConfig);
const shellStream = await ssh.requestShell();
const stdin = process.openStdin();
stdin.addListener("data",(data:Buffer) => {
shellStream.write(data.toString());
});
shellStream.on("data", (data:Buffer) => {
process.stdout.write(data.toString());
});
shellStream.stderr.on("data", (data:Buffer) => {
process.stdout.write(data.toString());
});
shellStream.on('close',()=>{
process.exit();
})
}
connect()
.catch((err)=>{
console.log("[#]","Error",err);
})