Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
396 lines (372 loc) · 20.2 KB
/
Copy pathindex.html
File metadata and controls
396 lines (372 loc) · 20.2 KB
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
385
386
387
388
389
390
391
392
393
394
395
396
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SSH Unique Keys</title>
<link rel="stylesheet" href="/assets/style.css">
{% if xterm_enabled %}
<link rel="stylesheet" href="/assets/vendor/xterm-5.5.0.css" />
<script src="/assets/vendor/xterm-5.5.0.js"></script>
<script src="/assets/vendor/xterm-addon-fit-0.10.0.js"></script>
{% endif %}
</head>
<body>
<div id="security-warning"
style="display:none; background-color: #d32f2f; color: white; text-align: center; padding: 10px; font-weight: bold;">
⚠️ SECURITY WARNING: Accessing via a non-local address is unsafe!
</div>
<div class="container">
<!-- Header & Nav -->
<div style="display:flex; justify-content: space-between; align-items: center; margin-bottom: 10px;">
<h1 style="margin:0;">SSH Key Manager</h1>
</div>
<div class="nav-bar">
<button class="nav-item active" onclick="switchView('dashboard')" id="nav-dashboard">Dashboard</button>
<button class="nav-item" onclick="switchView('templates')" id="nav-templates">Templates</button>
<button class="nav-item" onclick="switchView('history')" id="nav-history">History</button>
<div class="nav-right">
<a href="/logout" class="btn" style="background-color: #666; color: white;">Logout</a>
</div>
</div>
{% if get_flashed_messages() %}
<div style="background-color: #f5c6c6; color: #7a0000; padding: 10px; border-radius: 4px; margin-bottom: 20px;">
{{ get_flashed_messages()[0] }}
</div>
{% endif %}
<!-- DASHBOARD VIEW -->
<div id="view-dashboard" class="view-section active">
<div style="margin-bottom: 15px; text-align: right;">
<button class="btn btn-green" onclick="document.getElementById('createModal').style.display='block'">+
New Identity</button>
</div>
<table class="table" style="margin-top:0;">
<thead>
<tr>
<th style="width:30%">Host</th>
<th style="width:35%">Users</th>
<th style="width:25%">Our Key</th>
<th style="width:10%">Actions</th>
</tr>
</thead>
<tbody>
{% for identity in identities %}
{% set identity_loop = loop %}
{% if identity.users %}
{% for user in identity.users %}
<tr class="{{ 'group-odd' if identity_loop.index is odd else 'group-even' }}"
style="border-bottom: 1px solid #e0e0e0;">
{% if loop.first %}
<td rowspan="{{ identity.users|length }}" style="vertical-align: top; background-color: #fff;">
<div style="display: flex; align-items: center; justify-content: space-between;">
<div>
{% for alias in identity.aliases %}
<div style="font-weight: bold; padding-bottom: 2px;">{{ alias }}</div>
{% else %}
<span style="color: #999; font-style: italic;">(No alias)</span>
{% endfor %}
</div>
<button class="btn-copy" onclick="openInfoModal('{{ identity.uuid }}')"
title="View Host Details" style="margin-left: 10px;">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="10"></circle>
<line x1="12" y1="16" x2="12" y2="12"></line>
<line x1="12" y1="8" x2="12.01" y2="8"></line>
</svg>
</button>
</div>
</td>
{% endif %}
<td>
<div
style="display: inline-flex; align-items: center; margin-right: 5px; margin-bottom: 4px;">
<span class="badge badge-blue">{{ user.name }}</span>
<!-- Connection Actions -->
<button class="btn-copy"
onclick="prepareConnect('{{ identity.uuid }}', '{{ user.name }}')"
title="Connect in Terminal">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="4 17 10 11 4 5"></polyline>
<line x1="12" y1="19" x2="20" y2="19"></line>
</svg>
</button>
</div>
</td>
<td>
{% if user.is_template %}
<span class="badge badge-purple" title="This key template is inherited">Template: {{
user.template_name }}</span>
{% else %}
{% for ok in user.ssh_keys %}
<div style="display: inline-flex; align-items: center; margin-right: 5px;">
<span class="badge badge-gray">{{ ok.type }}</span>
<button class="btn-copy" onclick="copyToClipboard('{{ ok.content }}')"
title="Copy Public Key">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
</svg>
</button>
</div>
{% else %}
<span style="color:#ccc; font-style:italic; font-size:0.8em;">No key found</span>
{% endfor %}
{% endif %}
</td>
<td style="white-space: nowrap;">
<!-- Row Actions: Rotate & Delete -->
<button class="btn-copy" onclick="rotateUserKey('{{ identity.uuid }}', '{{ user.name }}')"
title="Rotate Key (Generate New, Install, Remove Old)"
style="color: #2196f3; margin-right: 5px;">
<span style="font-size:1.2em;">↻</span>
</button>
<button class="btn-copy" onclick="deleteUser('{{ identity.uuid }}', '{{ user.name }}')"
title="Delete User (Local)" style="color: #f44336;">
<span style="font-size:1.2em;">🗑</span>
</button>
</td>
</tr>
{% endfor %}
{% else %}
<tr>
<td>
<div style="display: flex; align-items: center; justify-content: space-between;">
<div>
{% for alias in identity.aliases %}
<div style="font-weight: bold; padding-bottom: 2px;">{{ alias }}</div>
{% else %}
<span style="color: #999; font-style: italic;">(No alias)</span>
{% endfor %}
</div>
<button class="btn-copy" onclick="openInfoModal('{{ identity.uuid }}')"
title="View Host Details" style="margin-left: 10px;">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="10"></circle>
<line x1="12" y1="16" x2="12" y2="12"></line>
<line x1="12" y1="8" x2="12.01" y2="8"></line>
</svg>
</button>
</div>
</td>
<td colspan="3" style="color: #999; font-style: italic;">No users found for this host UUID.</td>
</tr>
{% endif %}
{% else %}
<tr>
<td colspan="4" style="text-align: center; color: #777; padding: 20px;">No identities found.
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- TEMPLATES VIEW -->
<div id="view-templates" class="view-section">
<div style="display:flex; justify-content: space-between; align-items:center;">
<h2>Template Management</h2>
<button class="btn btn-blue" onclick="document.getElementById('templateCreateModal').style.display='block'">New Template</button>
</div>
<div id="templateList">Loading...</div>
</div>
<!-- HISTORY VIEW -->
<div id="view-history" class="view-section">
<div style="display:flex; justify-content: space-between; align-items:center;">
<h2>Operation History</h2>
<button class="btn btn-blue" onclick="fetchHistory()">Refresh</button>
</div>
<div style="background: #fff; border: 1px solid #ddd; border-radius: 4px; margin-top: 10px;">
<table class="table" style="margin-top: 0;">
<thead>
<tr style="background: #eee;">
<th>Time (UTC)</th>
<th>User</th>
<th>Action</th>
<th>Target</th>
<th style="width:40%">Details</th>
</tr>
</thead>
<tbody id="historyList"></tbody>
</table>
</div>
</div>
</div>
<!-- Modals (Create, Deploy, Info) -->
<!-- Create Modal -->
<div id="createModal" class="modal">
<div class="modal-content">
<h3>Add New Identity</h3>
<!-- Updated form to support Xterm Interception -->
<form action="/create" method="POST" onsubmit="handleCreateSubmit(event)">
<div style="margin-bottom: 10px;">
<label for="create_user_host">Target Host (user@hostname):</label><br>
<input type="text" name="user_host" id="create_user_host" required
style="width: 100%; padding: 5px;" placeholder="root@192.168.1.10">
</div>
<div style="margin-bottom: 10px;">
<label for="create_template_select">Template:</label><br>
<select name="template" id="create_template_select" style="width: 100%; padding: 5px;"
onchange="toggleKeyComment()">
<option value="none">None (Auto-detect Key Type)</option>
{% for t in templates %}
<option value="{{ t.name }}">{{ t.name }}</option>
{% endfor %}
</select>
</div>
<div style="margin-bottom: 10px;" id="create_key_comment_div">
<label for="create_key_comment">Key Comment (Public Key Description):</label><br>
<input type="text" name="key_comment" id="create_key_comment" style="width: 100%; padding: 5px;"
placeholder="e.g. user@host-date">
</div>
<div style="margin-bottom: 10px;">
<label style="display:flex; align-items:center; cursor:pointer;">
<input type="checkbox" name="legacy" id="create_legacy" style="margin-right: 8px;">
Enable legacy algorithms (RSA/DSS/CBC)
</label>
<small style="color: #b00; display: block; margin-top: 4px;">Warning: Only use for older devices (e.g. Cisco routers, old Linux) that don't support modern ciphers. Weakens security for this host only.</small>
</div>
<div style="text-align: right; margin-top: 20px;">
<button type="button" class="btn"
onclick="document.getElementById('createModal').style.display='none'">Cancel</button>
<button type="submit" class="btn btn-green">Create & Deploy</button>
</div>
</form>
</div>
</div>
<!-- Deploy Modal -->
<div id="deployModal" class="modal">
<div class="modal-content">
<h3>Deploy Key</h3>
<p>Deploy key for <strong id="deploy_user"></strong> to host?</p>
<form action="/deploy" method="POST">
<input type="hidden" name="uuid" id="deploy_uuid">
<input type="hidden" name="user" id="deploy_user_input">
<input type="hidden" name="target_host" id="deploy_target_host">
<div style="margin-bottom: 10px;">
<label for="deploy_password">Password (if needed):</label>
<input type="password" name="password" id="deploy_password" style="width: 100%; padding: 5px;">
</div>
<div style="text-align: right;">
<button type="button" class="btn"
onclick="document.getElementById('deployModal').style.display='none'">Cancel</button>
<button type="submit" class="btn btn-blue">Deploy</button>
</div>
</form>
</div>
</div>
<!-- Connect Modal -->
<div id="connectModal" class="modal">
<div class="modal-content">
<h3>Connect to Host</h3>
<p>Select the hostname to connect to:</p>
<form id="connectForm" onsubmit="return false;">
<input type="hidden" id="connect_user">
<div id="connect_aliases_list" style="margin-bottom: 20px; max-height: 200px; overflow-y: auto;">
<!-- Radio buttons injected here -->
</div>
<div style="text-align: right;">
<button type="button" class="btn"
onclick="document.getElementById('connectModal').style.display='none'">Cancel</button>
<button type="button" class="btn btn-blue" onclick="triggerConnectSubmit()">Connect</button>
</div>
</form>
</div>
</div>
<!-- Template Create Modal -->
<div id="templateCreateModal" class="modal">
<div class="modal-content">
<h3>Create New Template</h3>
<form onsubmit="return handleTemplateCreate(event)">
<div style="margin-bottom: 10px;">
<label for="tmpl_create_name">Template Name:</label><br>
<input type="text" id="tmpl_create_name" required
style="width: 100%; padding: 5px;" placeholder="e.g. work">
</div>
<div style="margin-bottom: 10px;">
<label for="tmpl_create_type">Key Type:</label><br>
<select id="tmpl_create_type" style="width: 100%; padding: 5px;">
<option value="standard">Standard Key (ed25519)</option>
<option value="sk">Hardware Key (FIDO2/YubiKey)</option>
<option value="opk">OpenPubKey (opkssh)</option>
</select>
</div>
<div style="text-align: right; margin-top: 20px;">
<button type="button" class="btn"
onclick="document.getElementById('templateCreateModal').style.display='none'">Cancel</button>
<button type="submit" class="btn btn-blue">Create</button>
</div>
</form>
</div>
</div>
<!-- TERMINAL MODAL (Xterm) -->
<div id="terminalModal" class="modal">
<div class="modal-content modal-large">
<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:10px;">
<h3 id="terminal-title" style="margin:0;">Terminal</h3>
<div>
<button id="btn-detach" class="btn btn-blue" onclick="detachTerminal()"
style="padding:4px 8px; font-size:0.8em; margin-right:5px;">Detach</button>
<button id="btn-close" class="btn btn-red" onclick="closeTerminal()"
style="padding:4px 8px; font-size:0.8em;">Close</button>
</div>
</div>
<div id="terminal-container"></div>
<button id="popout-close" onclick="window.close()" style="display:none;">Close</button>
</div>
</div>
<!-- Info Modal -->
<div id="infoModal" class="modal">
<div class="modal-content">
<h3>Host Details</h3>
<!-- ... content ... -->
<div style="margin-bottom: 10px;">
<strong>UUID:</strong> <span id="info_uuid" style="font-family: monospace;"></span>
</div>
<!-- Storage Path Removed -->
<div style="margin-bottom: 20px;">
<strong>Known Host Keys:</strong>
<div style="max-height: 200px; overflow-y: auto; background: #fafafa; border: 1px solid #ddd;">
<table class="table" style="margin:0; font-size: 0.9em;">
<thead>
<tr>
<th>Type</th>
<th>Fingerprint</th>
</tr>
</thead>
<tbody id="info_host_keys_body"></tbody>
</table>
</div>
</div>
<div style="text-align: right;">
<button type="button" class="btn"
onclick="document.getElementById('infoModal').style.display='none'">Close</button>
</div>
</div>
</div>
<div id="toast">Copied to clipboard!</div>
<!-- Result Modal (Auto-open if output exists) -->
{% if result_output %}
<div id="resultModal" class="modal" style="display:block">
<div class="modal-content">
<h3>Execution Result: {{ result_status|default('info')|upper }}</h3>
<pre
style="background:#f4f4f4; padding:10px; border:1px solid #ddd; overflow:auto; max-height:300px; font-size:0.9em;">{{ result_output }}</pre>
<div style="text-align: right; margin-top: 10px;">
<button class="btn" onclick="document.getElementById('resultModal').style.display='none'">Close</button>
</div>
</div>
</div>
{% endif %}
<!-- Initialization and External JS -->
<script type="application/json" id="app-data">
{
"identities": {{ identities | tojson }},
"xtermEnabled": {{ 'true' if xterm_enabled else 'false' }}
}
</script>
<script src="/assets/app.js"></script>
</body>
</html>