forked from withfig/autocomplete
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ssh.ts
384 lines (382 loc) · 11 KB
/
ssh.ts
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
const pastConnections: Fig.Generator = {
script: "history | cut -c 8- | grep -i '^ssh ' | sort --unique | less -SEXn",
postProcess: function (out) {
return out.split("\n").map((line) => {
const parts = line.split("/[ ,]+/");
let address;
for (let i = 0; i < parts.length; i++) {
if (parts[i].includes("@")) {
//found address
address = parts[i];
}
}
if (address) {
return {
name: "root",
icon: "🔗",
description: `connect to ${address}`,
};
}
});
},
};
const completionSpec: Fig.Spec = {
name: "ssh",
description: "Log into a remote machine",
args: [
{
name: "user@hostname",
description: "address of remote machine to log into",
generators: {
script: "cat ~/.ssh/config",
postProcess: function (out) {
return out
.split("\n")
.filter((line) => {
return line.trim().startsWith("Host ") && !line.includes("*");
})
.map((host) => {
return {
name: host.split(" ").slice(-1)[0],
description: "ssh host",
priority: 90,
};
});
},
},
},
],
options: [
{
name: ["-1"],
description: "Forces ssh to try protocol version 1 only..",
},
{
name: ["-2"],
description: "Forces ssh to try protocol version 2 only",
},
{
name: ["-4"],
description: "Forces ssh to use IPv4 addresses only.",
},
{
name: ["-6"],
description: "Forces ssh to use IPv6 addresses only.",
},
{
name: ["-A"],
description: "Enables forwarding of the authentication agent connection.",
},
{
name: ["-a"],
description:
"Disables forwarding of the authentication agent connection.",
},
{
name: ["-b"],
description:
"Use bind_address on the local machine as the source address of the connection.",
args: {
name: "bind address",
description: "source address of the connection",
},
},
{
name: ["-C"],
description:
"Requests compression of all data (including stdin, stdout, stderr, and data for forwarded X11 and TCP connections).",
},
{
name: ["-c"],
description:
"Selects the cipher specification for encrypting the session.",
args: {
name: "cipher spec",
description: "The selected cipher specification",
},
},
{
name: ["-D"],
description:
"Specifies a local 'dynamic' application-level port forwarding.",
args: {
name: "port",
description: "port of the bind address",
},
},
{
name: ["-e"],
description:
"Sets the escape character for sessions with a pty (default: '~').",
args: {
name: "escape char",
description: "Specified escape character",
},
},
{
name: ["-F"],
description: "Specifies an alternative per-user configuration file.",
args: {
name: "configfile",
description: "Path to alternative config file",
template: "filepaths",
},
},
{
name: ["-f"],
description:
"Requests ssh to go to background just before command execution.",
},
{
name: ["-g"],
description: "Allows remote hosts to connect to local forwarded ports.",
},
{
name: ["-I"],
description:
"Specify the PKCS#11 shared library ssh should use to communicate with a PKCS#11 token providing the user's private RSA key.",
args: {
name: "pkcs11",
},
},
{
name: ["-i"],
description:
"Selects a file from which the identity (private key) for public key authentication is read.",
args: {
name: "identity file",
description: "path to identity (private key)",
template: "filepaths",
},
},
{
name: ["-K"],
description:
"Enables GSSAPI-based authentication and forwarding (delegation) of GSSAPI credentials to the server.",
},
{
name: ["-k"],
description:
"Disables forwarding (delegation) of GSSAPI credentials to the server.",
},
{
name: ["-L"],
description:
"Specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side.",
args: {
name: "port:host:hostport",
description: "local port, followed by host and host port to forward to",
},
},
{
name: ["-l"],
description: "Specifies the user to log in as on the remote machine.",
args: {
name: "login name",
description: "Name of user logging into remote machine",
},
},
{
name: ["-M"],
description:
"Places the ssh client into ``master'' mode for connection sharing.",
},
{
name: ["-m"],
description:
"Additionally, for protocol version 2 a comma-separated list of MAC (message authentication code) algorithms can be specified in order of preference.",
args: {
name: "mac spec",
},
},
{
name: ["-N"],
description: "Do not execute a remote command.",
},
{
name: ["-n"],
description:
"Redirects stdin from /dev/null (actually, prevents reading from stdin).",
},
{
name: ["-O"],
description: "Control an active connection multiplexing master process.",
args: {
name: "ctl cmd",
description: "command that's passed to the master process",
},
},
{
name: ["-o"],
description:
"Can be used to give options in the format used in the configuration file.",
args: {
name: "option",
description:
"options that can be specified in the format of the config file",
suggestions: [
{ name: "AddressFamily" },
{ name: "BatchMode" },
{ name: "BindAddress" },
{ name: "ChallengeResponseAuthentication" },
{ name: "CheckHostIP" },
{ name: "Cipher" },
{ name: "Ciphers" },
{ name: "ClearAllForwardings" },
{ name: "Compression" },
{ name: "CompressionLevel" },
{ name: "ConnectionAttempts" },
{ name: "ConnectTimeout" },
{ name: "ControlMaster" },
{ name: "ControlPath" },
{ name: "ControlPersist" },
{ name: "DynamicForward" },
{ name: "EscapeChar" },
{ name: "ExitOnForwardFailure" },
{ name: "ForwardAgent" },
{ name: "ForwardX11" },
{ name: "ForwardX11Timeout" },
{ name: "ForwardX11Trusted" },
{ name: "GatewayPorts" },
{ name: "GlobalKnownHostsFile" },
{ name: "GSSAPIAuthentication" },
{ name: "GSSAPIDelegateCredentials" },
{ name: "HashKnownHosts" },
{ name: "Host" },
{ name: "HostbasedAuthentication" },
{ name: "HostKeyAlgorithms" },
{ name: "HostKeyAlias" },
{ name: "HostName" },
{ name: "IdentityFile" },
{ name: "IdentitiesOnly" },
{ name: "IPQoS" },
{ name: "KbdInteractiveAuthentication" },
{ name: "KbdInteractiveDevices" },
{ name: "KexAlgorithms" },
{ name: "LocalCommand" },
{ name: "LocalForward" },
{ name: "LogLevel" },
{ name: "MACs" },
{ name: "NoHostAuthenticationForLocalhost" },
{ name: "NumberOfPasswordPrompts" },
{ name: "PasswordAuthentication" },
{ name: "PermitLocalCommand" },
{ name: "PKCS11Provider" },
{ name: "Port" },
{ name: "PreferredAuthentications" },
{ name: "Protocol" },
{ name: "ProxyCommand" },
{ name: "PubkeyAuthentication" },
{ name: "RekeyLimit" },
{ name: "RequestTTY" },
{ name: "RhostsRSAAuthentication" },
{ name: "RSAAuthentication" },
{ name: "SendEnv" },
{ name: "ServerAliveInterval" },
{ name: "ServerAliveCountMax" },
{ name: "StrictHostKeyChecking" },
{ name: "TCPKeepAlive" },
{ name: "Tunnel" },
{ name: "TunnelDevice" },
{ name: "UsePrivilegedPort" },
{ name: "User" },
{ name: "UserKnownHostsFile" },
{ name: "VerifyHostKeyDNS" },
{ name: "VisualHostKey" },
{ name: "XAuthLocation" },
],
},
},
{
name: ["-p"],
description: "Port to connect to on the remote host.",
args: {
name: "port",
description: "port to connect to",
},
},
{
name: ["-q"],
description:
"Quiet mode. Causes most warning and diagnostic messages to be suppressed.",
},
{
name: ["-R"],
description:
"Specifies that the given port on the remote (server) host is to be forwarded to the given host and port on the local side.",
args: {
name: "port:host:hostport",
description: "local port, followed by host and host port to forward to",
},
},
{
name: ["-S"],
description:
"Specifies the location of a control socket for connection sharing, or the string 'none' to disable connection sharing.",
args: {
name: "ctl_path",
description: "location of the control socket",
template: "filepaths",
},
},
{
name: ["-s"],
description:
"May be used to request invocation of a subsystem on the remote system.",
},
{
name: ["-T"],
description: "Disable pseudo-tty allocation.",
},
{
name: ["-t"],
description: "Force pseudo-tty allocation.",
isRepeatable: true,
},
{
name: ["-V"],
description: "Display the version number and exit.",
},
{
name: ["-v"],
description:
"Verbose mode. Causes ssh to print debugging messages about its progress.",
isRepeatable: 3,
},
{
name: ["-W"],
description:
"Requests that standard input and output on the client be forwarded to host on port over the secure channel.",
args: {
name: "host:port",
description: "host and port to forward to",
},
},
{
name: ["-w"],
description:
"Requests tunnel device forwarding with the specified tun(4) devices between the client (local_tun) and the server (remote_tun).",
args: {
name: "local tun",
description: "local device to forward to",
},
},
{
name: ["-X"],
description: "Enables X11 forwarding.",
},
{
name: ["-x"],
description: "Disables X11 forwarding.",
},
{
name: ["-Y"],
description: "Enables trusted X11 forwarding.",
},
{
name: ["-y"],
description: "Send log information using the syslog(3) system module.",
},
],
};
export default completionSpec;