Repository navigation
Expand file tree
/
Copy pathssh.html
More file actions
216 lines (205 loc) · 14.9 KB
/
Copy pathssh.html
File metadata and controls
216 lines (205 loc) · 14.9 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
<!DOCTYPE html>
<html lang="de" class="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SSH Key Pair – CryptoStudio</title>
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = { darkMode: 'class', theme: { extend: {} } }
</script>
<script src="https://cdn.jsdelivr.net/npm/node-forge@1.3.1/dist/forge.min.js"></script>
<style>
:root { --bg:#090909; --bg-panel:#111111; --bg-soft:rgba(255,255,255,0.04); --text:#f5f5f5; --muted:#b9b9b9; --border:rgba(255,255,255,0.12); }
body.theme-light { --bg:#f5f3ef; --bg-panel:#ffffff; --bg-soft:rgba(17,17,17,0.03); --text:#111111; --muted:#4d4d4d; --border:rgba(17,17,17,0.08); }
body { background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, sans-serif; }
*::selection { background: rgba(255,255,255,0.18); color: var(--text); }
header, footer, .bg-slate-900\/60, .bg-slate-900\/40, .bg-slate-950, .bg-slate-900, .bg-slate-800 { background: var(--bg-panel) !important; border-color: var(--border) !important; }
.text-slate-300, .text-slate-400, .text-slate-500, .text-slate-200 { color: var(--muted) !important; }
.text-white, .text-slate-100 { color: var(--text) !important; }
.border-slate-800, .border-slate-700 { border-color: var(--border) !important; }
.bg-emerald-500\/10, .bg-emerald-600, .bg-emerald-600\/20, .bg-emerald-500 { background: var(--bg-soft) !important; border-color: var(--border) !important; color: var(--text) !important; }
.text-emerald-400, .text-emerald-300 { color: var(--text) !important; }
.theme-toggle { width:2.4rem; height:2.4rem; display:inline-flex; align-items:center; justify-content:center; border-radius:999px; border:1px solid var(--border); background: var(--bg-soft); color: var(--text); cursor: pointer; }
.brand-link { display:inline-flex; align-items:center; gap:0.5rem; padding:0.45rem 0.8rem; border-radius:999px; border:1px solid var(--border); background:var(--bg-soft); color:var(--text); font-size:0.72rem; letter-spacing:0.12em; text-transform:uppercase; }
.brand-mark { display:inline-flex; width:1.7rem; height:1.7rem; border-radius:999px; border:1px solid var(--border); background: var(--bg-soft); align-items:center; justify-content:center; font-size:0.7rem; font-weight:700; }
</style>
</head>
<body class="min-h-screen flex flex-col antialiased">
<div id="toast" class="fixed top-4 left-1/2 -translate-x-1/2 sm:left-auto sm:right-5 sm:translate-x-0 z-50 transform -translate-y-24 opacity-0 transition-all duration-300 pointer-events-none">
<div class="bg-slate-900/90 backdrop-blur-md text-white font-medium px-4 py-3 rounded-xl shadow-2xl flex items-center justify-center space-x-2 border border-slate-700 text-sm">
<svg class="w-5 h-5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" /></svg>
<span id="toastMsg">In die Zwischenablage kopiert!</span>
</div>
</div>
<header class="border-b border-slate-800/80 sticky top-0 z-40 backdrop-blur-md">
<div class="max-w-5xl mx-auto px-4 sm:px-6 py-4 flex items-center justify-between">
<a href="index.html" class="flex items-center space-x-3 group">
<div class="brand-mark">A</div>
<div>
<span class="font-bold text-lg tracking-tight">CryptoStudio</span>
<span class="block text-[11px] text-slate-400">Minimalist Cryptography Suite</span>
</div>
</a>
<div class="flex items-center gap-3">
<button id="themeToggle" class="theme-toggle" aria-label="Toggle theme">☼</button>
<a href="https://github.com/arien-dev" target="_blank" rel="noopener" class="brand-link"><span class="brand-mark">G</span> Made by arien-dev</a>
</div>
</div>
</header>
<main class="max-w-4xl mx-auto w-full px-4 sm:px-6 py-8 flex-grow">
<div class="mb-8 flex flex-col md:flex-row md:items-center justify-between gap-4 pb-6 border-b border-slate-800/80">
<div>
<span class="text-xs font-mono uppercase tracking-widest text-slate-300">SSH Module</span>
<h1 class="text-2xl sm:text-3xl font-black tracking-tight mt-1">SSH Schlüsselpaar Generierung</h1>
<p class="text-slate-400 text-xs sm:text-sm mt-1">Erzeuge OpenSSH-kompatible Schlüssel (id_rsa & id_rsa.pub) lokal für Serverzugriffe.</p>
</div>
<div class="inline-flex items-center space-x-2 bg-slate-900/60 border border-slate-800 px-3 py-1.5 rounded-full text-xs self-start md:self-auto">
<span class="w-2 h-2 rounded-full bg-white animate-pulse"></span>
<span>100% Lokale Berechnung</span>
</div>
</div>
<div class="bg-slate-900/60 border border-slate-800 rounded-2xl p-6 sm:p-8 shadow-xl backdrop-blur-md">
<form id="sshForm" onsubmit="generateSshKeyPair(event)" class="space-y-6">
<div class="grid grid-cols-1 sm:grid-cols-2 gap-5">
<div>
<label class="block text-xs font-semibold uppercase tracking-wider text-slate-300 mb-1.5">Schlüsseltyp & Länge</label>
<select id="sshKeyType" class="w-full bg-slate-950 border border-slate-800 rounded-xl px-4 py-2.5 text-slate-100 text-sm focus:border-white focus:ring-1 focus:ring-white outline-none">
<option value="rsa2048">RSA 2048 Bit</option>
<option value="rsa4096" selected>RSA 4096 Bit (Empfohlen)</option>
</select>
</div>
<div>
<label class="block text-xs font-semibold uppercase tracking-wider text-slate-300 mb-1.5">Kommentar / E-Mail</label>
<input type="text" id="sshComment" value="user@server.local" required class="w-full bg-slate-950 border border-slate-800 rounded-xl px-4 py-2.5 text-slate-100 text-sm focus:border-white focus:ring-1 focus:ring-white outline-none">
</div>
</div>
<div class="p-4 bg-slate-950 border border-slate-800 rounded-xl flex items-start space-x-3">
<input type="checkbox" id="sshTos" onchange="toggleSshSubmitBtn()" class="mt-0.5 rounded accent-white w-4 h-4 cursor-pointer">
<label for="sshTos" class="text-xs text-slate-300 cursor-pointer leading-relaxed">
Ich habe die <a href="terms.html" target="_blank" class="hover:underline font-medium">Nutzungsbedingungen</a> gelesen und akzeptiere diese.
</label>
</div>
<button type="submit" id="btnSshGenerate" disabled class="w-full bg-slate-800 hover:bg-slate-700 disabled:bg-slate-800 disabled:text-slate-500 disabled:cursor-not-allowed text-slate-100 text-sm font-semibold py-3 rounded-xl transition">
<span>SSH Schlüsselpaar lokal generieren</span>
</button>
</form>
<div id="sshStatus" class="hidden mt-8 text-center">
<div class="inline-flex items-center space-x-3 bg-slate-950 border border-slate-800 px-6 py-4 rounded-xl shadow-lg">
<svg class="animate-spin h-5 w-5 text-white flex-shrink-0" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg>
<span class="text-xs sm:text-sm font-medium text-slate-300">Generiere SSH-Schlüsselpaar...</span>
</div>
</div>
<div id="sshOutput" class="hidden mt-10 border-t border-slate-800 pt-8 space-y-6">
<div class="space-y-5">
<div>
<div class="flex flex-wrap justify-between items-center gap-2 mb-2">
<label class="text-xs sm:text-sm font-bold text-white">Öffentlicher SSH Schlüssel (id_rsa.pub)</label>
<div class="space-x-2">
<button onclick="copyToClipboard(generatedSsh.publicKey)" class="px-3 py-1 bg-slate-800 hover:bg-slate-700 text-xs font-medium rounded-lg transition">Kopieren</button>
<button onclick="downloadTextFile('id_rsa.pub', generatedSsh.publicKey)" class="px-3 py-1 bg-slate-900 text-white border border-slate-700 hover:bg-slate-800 text-xs font-medium rounded-lg transition">Download</button>
</div>
</div>
<textarea id="sshPubKeyArea" readonly class="w-full h-24 bg-slate-950 border border-slate-800 rounded-xl p-3.5 text-xs font-mono text-white focus:outline-none resize-none"></textarea>
</div>
<div>
<div class="flex flex-wrap justify-between items-center gap-2 mb-2">
<label class="text-xs sm:text-sm font-bold text-white">Privater SSH Schlüssel (id_rsa)</label>
<div class="space-x-2">
<button onclick="copyToClipboard(generatedSsh.privateKey)" class="px-3 py-1 bg-slate-800 hover:bg-slate-700 text-xs font-medium rounded-lg transition">Kopieren</button>
<button onclick="downloadTextFile('id_rsa', generatedSsh.privateKey)" class="px-3 py-1 bg-slate-900 text-white border border-slate-700 hover:bg-slate-800 text-xs font-medium rounded-lg transition">Download</button>
</div>
</div>
<textarea id="sshPrvKeyArea" readonly class="w-full h-40 bg-slate-950 border border-slate-800 rounded-xl p-3.5 text-xs font-mono text-slate-300 focus:outline-none resize-none"></textarea>
</div>
</div>
</div>
</div>
</main>
<footer class="border-t border-slate-800/80 py-6 text-center mt-auto">
<p class="text-xs text-slate-400">
© CryptoStudio – Minimalist & Secure Local Crypto Tools.
<a href="https://github.com/arien-dev" target="_blank" rel="noopener" class="underline hover:text-white ml-2">Made by arien-dev</a>
</p>
</footer>
<script>
const toggle = document.getElementById('themeToggle');
const applyTheme = (theme) => {
document.body.classList.toggle('theme-light', theme === 'light');
if (toggle) toggle.textContent = theme === 'dark' ? '☼' : '☾';
localStorage.setItem('cryptoTheme', theme);
};
applyTheme(localStorage.getItem('cryptoTheme') || 'dark');
if (toggle) toggle.addEventListener('click', () => applyTheme(document.body.classList.contains('theme-light') ? 'dark' : 'light'));
let generatedSsh = { publicKey: '', privateKey: '' };
function toggleSshSubmitBtn() {
const tosChecked = document.getElementById('sshTos').checked;
document.getElementById('btnSshGenerate').disabled = !tosChecked;
}
function copyToClipboard(text) {
if (!text) return;
navigator.clipboard.writeText(text).then(() => {
showToast('In die Zwischenablage kopiert!');
}).catch(err => {
showToast('Kopieren fehlgeschlagen: ' + err);
});
}
function showToast(msg) {
const toast = document.getElementById('toast');
document.getElementById('toastMsg').innerText = msg;
toast.classList.remove('-translate-y-24', 'opacity-0');
toast.classList.add('translate-y-0', 'opacity-100');
setTimeout(() => {
toast.classList.remove('translate-y-0', 'opacity-100');
toast.classList.add('-translate-y-24', 'opacity-0');
}, 2500);
}
function downloadTextFile(filename, content) {
const element = document.createElement('a');
element.href = 'data:text/plain;charset=utf-8,' + encodeURIComponent(content);
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
async function generateSshKeyPair(event) {
event.preventDefault();
if (!document.getElementById('sshTos').checked) {
alert('Bitte akzeptiere die Nutzungsbedingungen.');
return;
}
document.getElementById('sshStatus').classList.remove('hidden');
document.getElementById('sshOutput').classList.add('hidden');
setTimeout(async () => {
try {
const keyType = document.getElementById('sshKeyType').value;
const comment = document.getElementById('sshComment').value;
const bits = keyType === 'rsa4096' ? 4096 : 2048;
const keyPair = await window.crypto.subtle.generateKey({
name: 'RSASSA-PKCS1-v1_5',
modulusLength: bits,
publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
hash: 'SHA-256',
}, true, ['sign', 'verify']);
const prvBuffer = await window.crypto.subtle.exportKey('pkcs8', keyPair.privateKey);
const pubBuffer = await window.crypto.subtle.exportKey('spki', keyPair.publicKey);
const prvAsn1 = forge.asn1.fromDer(forge.util.createBuffer(new Uint8Array(prvBuffer)));
const prvKey = forge.pki.privateKeyFromAsn1(prvAsn1);
const pubAsn1 = forge.asn1.fromDer(forge.util.createBuffer(new Uint8Array(pubBuffer)));
const pubKey = forge.pki.publicKeyFromAsn1(pubAsn1);
generatedSsh.publicKey = forge.ssh.publicKeyToOpenSSH(pubKey, comment);
generatedSsh.privateKey = forge.pki.privateKeyToPem(prvKey);
document.getElementById('sshPubKeyArea').value = generatedSsh.publicKey;
document.getElementById('sshPrvKeyArea').value = generatedSsh.privateKey;
document.getElementById('sshStatus').classList.add('hidden');
document.getElementById('sshOutput').classList.remove('hidden');
} catch (err) {
alert('Fehler bei SSH-Generierung: ' + err.message);
document.getElementById('sshStatus').classList.add('hidden');
}
}, 50);
}
</script>
</body>
</html>