WebsiteTemplate/cheatsheets/ssh-keygen.html
2026-01-25 11:33:37 -04:00

144 lines
6.0 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self'; font-src 'self' data:; img-src 'self' data:; connect-src 'self'; base-uri 'self'; form-action 'self' https://defcon.social https://bsky.app;">
<meta http-equiv="X-Content-Type-Options" content="nosniff">
<link rel="stylesheet" href="../assets/css/style.css">
<link rel="icon" type="image/x-icon" href="../favicon.ico">
<script>
// Apply theme immediately to prevent flash
(function() {
const theme = localStorage.getItem('theme') ||
(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
document.documentElement.setAttribute('data-theme', theme);
})();
</script>
<title>ssh-keygen Cheatsheet - Launch Pad</title>
</head>
<body>
<button class="theme-toggle" id="themeToggle" aria-label="Toggle dark mode">
<svg class="theme-icon theme-icon-moon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path></svg>
<svg class="theme-icon theme-icon-sun" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display: none;"><circle cx="12" cy="12" r="5"></circle><line x1="12" y1="1" x2="12" y2="3"></line><line x1="12" y1="21" x2="12" y2="23"></line><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line><line x1="1" y1="12" x2="3" y2="12"></line><line x1="21" y1="12" x2="23" y2="12"></line><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line></svg>
</button>
<br/><br/>
<div class="name">
__ _______________________ _________._________________________
\_ _____/ \______ \ / _ \ / _____/ / _____/ | | \_ _____/
| __) | _/ / /_\ \ / \ ___ / \ ___ | | | __)_
| \ | | \ / | \ \ \_\ \ \ \_\ \ | |___ | \
\___ / |____|_ / \____|__ / \______ / \______ / |_______ \ /_______ /
\/ \/ \/ \/ \/ \/ \/
</div>
<div class="blog-page-header">
<div class="blog-header-content">
<a href="/cheatsheets" class="back-link" title="Back to Cheatsheets">
<svg xmlns="http://www.w3.org/2000/svg" width="42" height="42" viewBox="0 0 24 24" class="home-icon"><path fill="currentColor" d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/></svg>
</a>
<h1 class="blog-page-title">ssh-keygen Cheatsheet</h1>
</div>
</div>
<div class="blog-post-container">
<div class="blog-posts-container" style="max-width: 900px; margin: 0 auto;">
<div class="blog-post">
<div class="blog-post-content">
<p><a href="index.html">← Back to cheatsheets</a></p>
<p><a href="../index.html">← Home</a></p>
<hr>
<p>ssh-keygen generates, manages, and converts SSH authentication keys. Essential for passwordless SSH access and secure key-based authentication.</p>
<hr>
<h2>Key Generation</h2>
<ul>
<li>ssh-keygen -t ed25519 - Generate Ed25519 key (recommended)</li>
</ul>
<ul>
<li>ssh-keygen -t rsa -b 4096 - Generate RSA key (4096 bits)</li>
</ul>
<ul>
<li>ssh-keygen -t ecdsa -b 256 - Generate ECDSA key</li>
</ul>
<ul>
<li>ssh-keygen -f ~/.ssh/id_ed25519 - Specify key file location</li>
</ul>
<ul>
<li>ssh-keygen -C "comment" - Add comment to key</li>
</ul>
<hr>
<h2>Key Management</h2>
<ul>
<li>ssh-keygen -l -f ~/.ssh/id_ed25519.pub - Show key fingerprint</li>
</ul>
<ul>
<li>ssh-keygen -y -f ~/.ssh/id_ed25519 - Extract public key from private key</li>
</ul>
<ul>
<li>ssh-keygen -p -f ~/.ssh/id_ed25519 - Change passphrase</li>
</ul>
<ul>
<li>ssh-keygen -R hostname - Remove host from known_hosts</li>
</ul>
<hr>
<h2>Key Conversion</h2>
<ul>
<li>ssh-keygen -p -m PEM -f old_key - Convert key format</li>
</ul>
<ul>
<li>ssh-keygen -e -f id_rsa.pub -m RFC4716 - Convert to RFC4716 format</li>
</ul>
<ul>
<li>ssh-keygen -i -f publickey - Import key in other formats</li>
</ul>
<hr>
<h2>Common Examples</h2>
<h3>Generate Ed25519 Key</h3>
<pre><code>ssh-keygen -t ed25519 -C "your_email@example.com"</code></pre>
<p>Generate modern Ed25519 key with email comment.</p>
<h3>Generate RSA Key</h3>
<pre><code>ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa</code></pre>
<p>Generate 4096-bit RSA key.</p>
<h3>Show Fingerprint</h3>
<pre><code>ssh-keygen -l -f ~/.ssh/id_ed25519.pub</code></pre>
<p>Display key fingerprint for verification.</p>
<h3>Change Passphrase</h3>
<pre><code>ssh-keygen -p -f ~/.ssh/id_ed25519</code></pre>
<p>Change passphrase on existing key.</p>
<h3>Copy Public Key</h3>
<pre><code>cat ~/.ssh/id_ed25519.pub</code></pre>
<p>Display public key to copy to server.</p>
<h3>Remove Host Key</h3>
<pre><code>ssh-keygen -R example.com</code></pre>
<p>Remove host from known_hosts (after key change).</p>
<hr>
<h2>Tips</h2>
<ul>
<li>Ed25519 is preferred: smaller, faster, and more secure than RSA</li>
</ul>
<ul>
<li>Use RSA 4096-bit minimum if Ed25519 isn't supported</li>
</ul>
<ul>
<li>Always use passphrases for private keys</li>
</ul>
<ul>
<li>Keep private keys secure (~/.ssh/id_*), never share them</li>
</ul>
<ul>
<li>Public keys (.pub) are safe to share</li>
</ul>
<ul>
<li>Use ssh-copy-id to easily copy keys to servers</li>
</ul>
<ul>
<li>Verify fingerprints out-of-band before trusting new hosts</li>
</ul>
</div>
</div>
</div>
</div>
<script async type="text/javascript" src="../blog/analytics.js"></script>
<script src="../theme.js"></script>
</body>
</html>