ssh_tunnel_proxy 1.2.10 → 2.0.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.
Files changed (39) hide show
  1. package/README.md +144 -67
  2. package/dist/cjs/index.d.ts +65 -0
  3. package/dist/cjs/index.js +496 -0
  4. package/dist/cjs/index.js.map +1 -0
  5. package/dist/cjs/keypair_storage.d.ts +12 -0
  6. package/dist/cjs/keypair_storage.js +60 -0
  7. package/dist/cjs/keypair_storage.js.map +1 -0
  8. package/dist/cjs/ngrok_service.d.ts +11 -0
  9. package/dist/cjs/ngrok_service.js +40 -0
  10. package/dist/cjs/ngrok_service.js.map +1 -0
  11. package/dist/cjs/ssh2-node.d.ts +1 -0
  12. package/dist/cjs/ssh2-node.js +188 -0
  13. package/dist/cjs/ssh2-node.js.map +1 -0
  14. package/dist/esm/index.d.ts +65 -0
  15. package/dist/esm/index.js +491 -0
  16. package/dist/esm/index.js.map +1 -0
  17. package/dist/esm/keypair_storage.d.ts +12 -0
  18. package/dist/esm/keypair_storage.js +57 -0
  19. package/dist/esm/keypair_storage.js.map +1 -0
  20. package/dist/esm/ngrok_service.d.ts +11 -0
  21. package/dist/esm/ngrok_service.js +37 -0
  22. package/dist/esm/ngrok_service.js.map +1 -0
  23. package/dist/esm/ssh2-node.d.ts +1 -0
  24. package/dist/esm/ssh2-node.js +184 -0
  25. package/dist/esm/ssh2-node.js.map +1 -0
  26. package/dist/types/index.d.ts +65 -0
  27. package/dist/types/keypair_storage.d.ts +12 -0
  28. package/dist/types/ngrok_service.d.ts +11 -0
  29. package/dist/types/ssh2-node.d.ts +1 -0
  30. package/package.json +38 -8
  31. package/ssh2-node +2 -0
  32. package/.eslintrc.json +0 -15
  33. package/.vscode/launch.json +0 -34
  34. package/lib/index.js +0 -472
  35. package/lib/keypair_storage.js +0 -76
  36. package/lib/ngrok_service.js +0 -47
  37. package/main.js +0 -176
  38. package/test/test.js +0 -214
  39. package/test/test_remote_exec.js +0 -219
@@ -0,0 +1,188 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.main = void 0;
40
+ var process = require("process");
41
+ var fs_1 = require("fs");
42
+ var os_1 = require("os");
43
+ var commander_1 = require("commander");
44
+ var index_1 = require("./index");
45
+ function get_default_config() {
46
+ var configs = [];
47
+ try {
48
+ configs = JSON.parse((0, fs_1.readFileSync)((0, os_1.homedir)() + '/.config/ssh_tunnel_proxy/config.json').toString());
49
+ }
50
+ catch (err) {
51
+ console.log('Error loading config file:', err);
52
+ }
53
+ return configs;
54
+ }
55
+ function main() {
56
+ var _this = this;
57
+ var program = new commander_1.Command();
58
+ program
59
+ .name('ssh2-node')
60
+ .description('Nodejs ssh2 command line client')
61
+ .version('1.2.12')
62
+ .option('-4 --forceIPv4 [forceIPv4]', 'Only connect via resolved IPv4 address for host. Default: false')
63
+ .option('-6 --forceIPv6 [forceIPv6]', 'Only connect via resolved IPv6 address for host. Default: false')
64
+ .option('-b --bind [bind]', 'bind_address')
65
+ .option('-C --compress [compress]', 'Requests compression of all data')
66
+ .option('-c --cipher [cipher]', 'cipher_spec')
67
+ .option('-D --dynamic_forward [dynamic_forward]', " Specifies a local 'dynamic' application-level port forwarding.")
68
+ .option('-e --escape [escape]', 'escape_char Sets the escape character for sessions with a pty.')
69
+ .option('-F --config [config]', 'configfile')
70
+ .option('-f --background [background]', 'Requests ssh to go to background just before command execution.')
71
+ .option('-g --local_forward_remote [local_forward_remote]', 'Allows remote hosts to connect to local forwarded ports.')
72
+ .option('-i --identity [identity]', 'Private key filename.')
73
+ .option('-L --local_forward_out [local_forward_out...]', 'bind_address:port:host:hostport')
74
+ .option('-l --login_name [login_name]', 'login_name')
75
+ .option('-N --no_exec [no_exec]', 'Do not execute a remote command.')
76
+ .option('-n --redirect_stdin [redirect_stdin]', 'Redirects stdin from /dev/null')
77
+ .option('-o --option [option]', 'option')
78
+ .option('-p --port [port]', 'port Port to connect to on the remote host.')
79
+ .option('-q --quiet [quiet]', 'Quiet mode. Causes most warning and diagnostic messages to be suppressed.')
80
+ .option('-R --local_forward_in [local_forward_in...]', 'bind_address:port:host:hostport')
81
+ .option('-s --subsystem [subsystem]', 'May be used to request invocation of a subsystem on the remote system.')
82
+ .option('-T --disable_tty [disable_tty]', 'Disable pseudo-tty allocation.')
83
+ .option('-t --force_tty [force_tty]', 'Force pseudo-tty allocation.')
84
+ .option('-V --version [version]', 'Display the version number and exit.')
85
+ .option('-v --verbose [verbose]', 'Verbose mode. Causes ssh to print debugging messages about its progress.')
86
+ .option('-W --forward_stdin_stdout [forward_stdin_stdout]', 'host:port Requests that standard input and output on the client be forwarded to host on port ver the secure channel.')
87
+ .option('-X --x11 [x11]', 'Enables X11 forwarding.')
88
+ .option('-x --x11_disable [x11_disable]', 'Disables X11 forwarding.')
89
+ .option('-Y --x11_trusted [x11_trusted]', 'Enables trusted X11 forwarding.')
90
+ .option('-y --log [log]', 'Send log information using the syslog(3)')
91
+ .option('-H --ngrok [ngrok]', 'Obtain connectiion hostport from ngrok')
92
+ .option('-J --keychain_service [keychain_service]', 'Service name to obtain private key from system keychain.')
93
+ .option('-j --keychain_account [keychain_account]', 'Account name to obtain private key from system keychain.')
94
+ .argument('[userhost_arg]', 'Connect to hostname in config.')
95
+ .argument('[exec...]', 'Command to exec on remote host.');
96
+ program.parse(process.argv);
97
+ var opts = program.opts();
98
+ var args = program.processedArgs;
99
+ var username = '';
100
+ var config_host = '';
101
+ var host = '';
102
+ var userhost_arg = "".concat(args[0]);
103
+ args.shift();
104
+ var cmd = args.join(' ');
105
+ var exec = [];
106
+ if (cmd.length > 0)
107
+ exec.push(cmd);
108
+ if (userhost_arg) {
109
+ if (userhost_arg.indexOf('@') >= 0) {
110
+ var userhost = userhost_arg.split('@');
111
+ username = userhost[0];
112
+ host = userhost[1];
113
+ }
114
+ else {
115
+ config_host = userhost_arg;
116
+ }
117
+ }
118
+ else {
119
+ console.log('user@host or host name in config not provided');
120
+ return;
121
+ }
122
+ var configs = [];
123
+ if (config_host) {
124
+ configs = get_default_config();
125
+ }
126
+ if (!config_host) {
127
+ var config = {
128
+ hostname: 'cli',
129
+ username: username,
130
+ host: host,
131
+ private_key_filename: opts.identity.trim(),
132
+ };
133
+ configs = [config];
134
+ }
135
+ var keypairStorage = new index_1.KeypairStorage();
136
+ var remote_server = '';
137
+ configs.forEach(function (config) { return __awaiter(_this, void 0, void 0, function () {
138
+ var service_name, _a, sshTunnelProxy;
139
+ return __generator(this, function (_b) {
140
+ switch (_b.label) {
141
+ case 0:
142
+ if (config.disabled)
143
+ return [2];
144
+ if (config_host && config_host !== config.hostname)
145
+ return [2];
146
+ remote_server = config_host;
147
+ if (!config.service_name) return [3, 2];
148
+ config.server_name = config.hostname || config_host || 'ssh_tunnel_proxy';
149
+ service_name = config.service_name || 'ssh_client';
150
+ _a = config;
151
+ return [4, keypairStorage.get_keypair(service_name, config.server_name)];
152
+ case 1:
153
+ _a.private_key = _b.sent();
154
+ _b.label = 2;
155
+ case 2:
156
+ opts.port && (config.port = opts.port);
157
+ opts.local_forward_out && (config.proxy_ports = opts.local_forward_out);
158
+ opts.local_forward_in && (config.remote_ports = opts.local_forward_in);
159
+ opts.keychain_service && (config.service_name = opts.keychain_service);
160
+ opts.keychain_account && (config.server_name = opts.keychain_account);
161
+ opts.ngrok && (config.ngrok_api = opts.ngrok);
162
+ opts.identity && (config.private_key_filename = opts.identity.trim());
163
+ opts.compress && (config.compress = opts.compress);
164
+ opts.cypher && (config.cypher = opts.cypher);
165
+ if (exec.length > 0) {
166
+ config.exec = exec;
167
+ }
168
+ else {
169
+ config.shell = true;
170
+ }
171
+ sshTunnelProxy = new index_1.SSHTunnelProxy();
172
+ sshTunnelProxy.debug_en = opts.verbose;
173
+ return [4, sshTunnelProxy.connectSSH(config, null)];
174
+ case 3:
175
+ _b.sent();
176
+ if (exec.length > 0) {
177
+ process.exit();
178
+ }
179
+ return [2];
180
+ }
181
+ });
182
+ }); });
183
+ if (config_host && !remote_server) {
184
+ console.log("Remote host ".concat(config_host, " not found"));
185
+ }
186
+ }
187
+ exports.main = main;
188
+ //# sourceMappingURL=ssh2-node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ssh2-node.js","sourceRoot":"","sources":["../../src/ssh2-node.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,iCAAmC;AACnC,yBAAkC;AAClC,yBAA6B;AAC7B,uCAAoC;AACpC,iCAAoE;AAGpE,SAAS,kBAAkB;IACzB,IAAI,OAAO,GAAqB,EAAE,CAAC;IACnC,IAAI;QACF,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,iBAAY,EAAC,IAAA,YAAO,GAAE,GAAG,uCAAuC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;KACpG;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO,CAAC,GAAG,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;KAChD;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAgB,IAAI;IAApB,iBA0JC;IAzJC,IAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;IAE9B,OAAO;SACJ,IAAI,CAAC,WAAW,CAAC;SACjB,WAAW,CAAC,iCAAiC,CAAC;SAC9C,OAAO,CAAC,QAAQ,CAAC;SAEjB,MAAM,CAAC,4BAA4B,EAAE,iEAAiE,CAAC;SACvG,MAAM,CAAC,4BAA4B,EAAE,iEAAiE,CAAC;SAGvG,MAAM,CAAC,kBAAkB,EAAE,cAAc,CAAC;SAC1C,MAAM,CAAC,0BAA0B,EAAE,kCAAkC,CAAC;SACtE,MAAM,CAAC,sBAAsB,EAAE,aAAa,CAAC;SAC7C,MAAM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,CAAC,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,CAAC;oBACtE,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;oBAC9C,IAAI,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,oBAAoB,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;oBACtE,IAAI,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;oBACnD,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;oBAG7C,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;wBACnB,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;qBACpB;yBAAM;wBACL,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC;qBACrB;oBAGK,cAAc,GAAG,IAAI,sBAAc,EAAE,CAAC;oBAC5C,cAAc,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC;oBACvC,WAAM,cAAc,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,EAAA;;oBAA7C,SAA6C,CAAC;oBAG9C,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;wBACnB,OAAO,CAAC,IAAI,EAAE,CAAC;qBAChB;;;;SACF,CAAC,CAAC;IAGH,IAAI,WAAW,IAAI,CAAC,aAAa,EAAE;QACjC,OAAO,CAAC,GAAG,CAAC,sBAAe,WAAW,eAAY,CAAC,CAAC;KACrD;AACH,CAAC;AA1JD,oBA0JC"}
@@ -0,0 +1,65 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ /// <reference types="node" />
5
+ import { Server, Socket } from 'net';
6
+ import { Writable } from 'stream';
7
+ import { EventEmitter } from 'events';
8
+ import { Client, Channel } from 'electron-ssh2';
9
+ import { KeypairStorage } from './keypair_storage';
10
+ import { NgrokApi } from './ngrok_service';
11
+ import { main } from './ssh2-node';
12
+ interface Listener {
13
+ [key: string]: Server;
14
+ }
15
+ export type SSHConfig = {
16
+ hostname: string;
17
+ username: string;
18
+ password?: string;
19
+ host?: string;
20
+ port?: string;
21
+ proxy_ports?: Array<string>;
22
+ remote_ports?: Array<string>;
23
+ private_key?: string | null;
24
+ private_key_filename?: string | null;
25
+ disabled?: boolean;
26
+ server_name?: string;
27
+ service_name?: string;
28
+ compress?: string;
29
+ cypher?: string;
30
+ exec?: Array<string>;
31
+ shell?: boolean;
32
+ ngrok_api?: string;
33
+ keepaliveInterval?: number;
34
+ };
35
+ export declare class SSHTunnelProxy extends EventEmitter {
36
+ protected client: Client;
37
+ protected keypairStorage: KeypairStorage;
38
+ protected config: SSHConfig;
39
+ protected listener: Listener;
40
+ protected retries: number;
41
+ protected networkOnline: boolean;
42
+ protected _tunnelReadyTimeout: ReturnType<typeof setTimeout>;
43
+ debug_en: boolean;
44
+ debug_ssh: boolean;
45
+ constructor();
46
+ protected close_sockets(proxy_ports: Array<string>): void;
47
+ protected setup_ssh_forward(socket: Socket, remote_hostname: string, remote_port: string): void;
48
+ setupProxyPorts(proxy_ports: Array<string>): Promise<void>;
49
+ execCmd(cmd: string, dataStream?: Writable, errStream?: Writable): Promise<void>;
50
+ protected remote_shell(err: Error, stream: Channel): void;
51
+ protected cleanup_events(client: Client): void;
52
+ do_ssh_connect(opts: SSHConfig): Promise<void>;
53
+ validate_port_number(port: number, whitelist: object): boolean;
54
+ validate_local_forward(proxy_ports: Array<string>, whitelist: object): boolean;
55
+ protected ssh_retry_connect(opts: SSHConfig): void;
56
+ protected ssh_start_tunnel(opts: SSHConfig): Promise<unknown>;
57
+ connectSSH(opts: SSHConfig, whitelist: object | null): Promise<void>;
58
+ onNetworkOnline(): void;
59
+ onNetworkOffline(): void;
60
+ generateAndStoreKeypair(serviceName: string, account: string): void;
61
+ getPublicKey(serviceName: string, account: string): void;
62
+ getClient(): Client;
63
+ protected debug(...args: any[]): void;
64
+ }
65
+ export { KeypairStorage, NgrokApi, main as sshcli };