<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>svnscha - sysadmin</title>
    <subtitle>automating annoying tasks, sharing tips, and embracing less frustration</subtitle>
    <link rel="self" type="application/atom+xml" href="https://svnscha.de/tags/sysadmin/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://svnscha.de"/>
    <generator uri="https://astro.build/">Astro</generator>
    <updated>2024-10-04T00:00:00+00:00</updated>
    <id>https://svnscha.de/tags/sysadmin/atom.xml</id>
    <entry xml:lang="en">
        <title>Where's /etc/pve/firewall/cluster.fw in rescue images?</title>
        <published>2024-10-04T00:00:00+00:00</published>
        <updated>2024-10-04T00:00:00+00:00</updated>
        <author>
          <name>Sven Scharmentke</name>
        </author>
        <link rel="alternate" type="text/html" href="https://svnscha.de/posts/proxmox-rescue-firewall-disable/"/>
        <id>https://svnscha.de/posts/proxmox-rescue-firewall-disable/</id>
        <summary type="html">Ah, so you've locked yourself out of your own Proxmox server. Don't worry, happens.</summary>
        <content type="html" xml:base="https://svnscha.de/posts/proxmox-rescue-firewall-disable/">&lt;h2 id=&quot;why-you-ask&quot;&gt;Why, You Ask?&lt;/h2&gt;
&lt;p&gt;If a firewall rule has locked you out of a Proxmox server, you can disable the firewall from a rescue system. Here is the process I used to regain access.&lt;/p&gt;
&lt;h2 id=&quot;step-1-mount-the-proxmox-system&quot;&gt;Step 1: Mount the Proxmox System&lt;/h2&gt;
&lt;p&gt;First, you need to access your Proxmox filesystem. If you're using LVM (Logical Volume Management), this step is pretty straightforward:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;mount&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; /dev/mapper/vg0-root&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; /mnt&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With your filesystem mounted, chroot into it:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;chroot&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; /mnt/&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now you're inside your system, ready to work some magic.&lt;/p&gt;
&lt;h2 id=&quot;step-2-disabling-the-firewall&quot;&gt;Step 2: Disabling the Firewall&lt;/h2&gt;
&lt;p&gt;The firewall is likely what caused you to get locked out, so we'll need to disable it temporarily. Run the following commands:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;systemctl&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; disable&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; pve-firewall&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;systemctl&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; mask&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; pve-firewall&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Once you've done that, reboot the server. You should now be able to reconnect to your system normally, without the firewall cutting you off.&lt;/p&gt;
&lt;h2 id=&quot;step-3-fix-the-issue-and-restore-the-firewall&quot;&gt;Step 3: Fix the Issue and Restore the Firewall&lt;/h2&gt;
&lt;p&gt;After fixing whatever issue got you locked out, it's time to re-enable the firewall. Run these commands to restore it:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;systemctl&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; unmask&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; pve-firewall&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;systemctl&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; enable&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; pve-firewall&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;systemctl&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; start&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; pve-firewall&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Your firewall should now be back up and running, but without the lockout problem.&lt;/p&gt;
&lt;h2 id=&quot;a-note-about-etcpvefirewallclusterfw&quot;&gt;A Note About &lt;code&gt;/etc/pve/firewall/cluster.fw&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;If you're hunting for &lt;code&gt;/etc/pve/firewall/cluster.fw&lt;/code&gt; while in rescue mode, hoping it's a typical file you can modify directly, you're out of luck. This file is part of Proxmox's cluster-wide configuration and is not stored as a regular file on the disk. Instead, it's managed through Proxmox's internal database, which is part of the &lt;a href=&quot;https://pve.proxmox.com/wiki/Proxmox_Cluster_File_System_(pmxcfs)&quot;&gt;Proxmox Cluster File System (pmxcfs)&lt;/a&gt;. As such, it doesn't exist as a standalone file you can access from rescue mode. To modify this configuration, you'll need to regain full access to Proxmox and make changes from within the Proxmox interface or by editing it via the proper tools once you're back online.&lt;/p&gt;
&lt;h2 id=&quot;summary&quot;&gt;Summary&lt;/h2&gt;
&lt;p&gt;And there you have it! With your system back up and running, and the firewall behaving, you can get back to managing your Proxmox server. Just be cautious next time you tweak the firewall rules  -  locking yourself out isn't the most fun way to spend your day!&lt;/p&gt;
</content>
    </entry>
    <entry xml:lang="en">
        <title>Simplify SSH</title>
        <published>2024-10-03T00:00:00+00:00</published>
        <updated>2024-10-03T00:00:00+00:00</updated>
        <author>
          <name>Sven Scharmentke</name>
        </author>
        <link rel="alternate" type="text/html" href="https://svnscha.de/posts/simplify-ssh/"/>
        <id>https://svnscha.de/posts/simplify-ssh/</id>
        <summary type="html">How to stop typing your SSH Key passphrase every time. (because, let's be real, we're all a little lazy)</summary>
        <content type="html" xml:base="https://svnscha.de/posts/simplify-ssh/">&lt;h2 id=&quot;why-you-ask&quot;&gt;Why, You Ask?&lt;/h2&gt;
&lt;p&gt;I was tired of entering my SSH key passphrase every time I connected to a server. The setup below lets &lt;code&gt;ssh-agent&lt;/code&gt; remember it for the current terminal session and also keeps host settings in one place.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;It's time-consuming and frustrating. I'm tired of it.&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&quot;getting-started&quot;&gt;Getting Started&lt;/h2&gt;
&lt;p&gt;So, you've got your shiny new SSH key and every time you want to connect to a server, you're greeted with that ever-familiar password prompt. Sure, typing your SSH key passphrase every time is good for security, but, come on  -  who wants to do that? I mean, I don't know about you, but I've got enough passwords to remember without constantly dealing with this nonsense.&lt;/p&gt;
&lt;p&gt;Let's save ourselves some time and effort by getting the SSH agent to remember our keys for us. That way, you can just run your commands like the seasoned developer you are without worrying about the whole &quot;password entering&quot; thing every single time.&lt;/p&gt;
&lt;h2 id=&quot;step-1-start-the-ssh-agent&quot;&gt;Step 1: Start the SSH Agent&lt;/h2&gt;
&lt;p&gt;First things first  -  let's get the SSH agent up and running. It's like your personal SSH butler, here to remember your key so you don't have to.&lt;/p&gt;
&lt;p&gt;Open up your terminal and type:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;eval&lt;/span&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt; $(&lt;/span&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;ssh-agent&lt;/span&gt;&lt;span style=&quot;color:#569CD6&quot;&gt; -s&lt;/span&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Boom! Now the agent is running in the background, ready to hold your keys like the responsible little daemon it is.&lt;/p&gt;
&lt;h2 id=&quot;step-2-add-your-key-to-the-ssh-agent&quot;&gt;Step 2: Add your key to the SSH Agent&lt;/h2&gt;
&lt;p&gt;Now that the agent is up, let's give it your key. You only need to do this once per session, and the agent will keep it ready for you.&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;ssh-add&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; ~/.ssh/your_key&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Replace &lt;code&gt;your_key&lt;/code&gt; with the name of your private key file. Enter the passphrase once and &lt;code&gt;ssh-agent&lt;/code&gt; will remember it for the rest of the terminal session.&lt;/p&gt;
&lt;h2 id=&quot;step-3-configure-your-ssh-setup-to-be-even-lazier-i-mean-efficient&quot;&gt;Step 3: Configure your SSH setup to be even lazier (I mean efficient)&lt;/h2&gt;
&lt;p&gt;Okay, we've got the agent running and the key added, but we can take it one step further. Why not tell SSH exactly what key to use for which server, so you never have to worry about it picking the wrong one?&lt;/p&gt;
&lt;p&gt;To do this, we're going to set up a &lt;code&gt;~/.ssh/config&lt;/code&gt; file. If you don't have this file yet, don't worry  -  it's as easy as creating it:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;touch&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; ~/.ssh/config&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, crack open that file with your favorite text editor and set things up like this:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;Host&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; your-server-alias&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;    HostName&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; your.server.com&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;    User&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; your-username&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;    IdentityFile&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; ~/.ssh/your_key&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;    IdentitiesOnly&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; yes&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;breaking-it-down&quot;&gt;Breaking it down&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Host&lt;/strong&gt;: You can use any alias here that makes sense to you. This is what you'll type when you want to connect to this server.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;HostName&lt;/strong&gt;: The actual domain or IP address of the server.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;User&lt;/strong&gt;: Your username on that server, so you do not have to specify it each time.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IdentityFile&lt;/strong&gt;: The path to your SSH private key.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IdentitiesOnly yes&lt;/strong&gt;: Tells SSH to use &lt;em&gt;only&lt;/em&gt; this key, rather than trying every key it can find in the agent (which is how you avoid that annoying &quot;user mismatch&quot; issue).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;step-4-create-a-wrapper-script-for-ssh-agent-control&quot;&gt;Step 4: Create a wrapper script for SSH Agent control&lt;/h2&gt;
&lt;p&gt;Alright, you want control over when your SSH agent starts up  -  totally understandable! Instead of running the agent automatically on login (which might feel a bit &lt;em&gt;too&lt;/em&gt; autonomous), we'll create a neat little wrapper script. You can trigger it whenever you feel like starting the agent and adding your SSH key for the session.&lt;/p&gt;
&lt;p&gt;Here's how to set that up.&lt;/p&gt;
&lt;h3 id=&quot;create-the-wrapper-script&quot;&gt;Create the wrapper script&lt;/h3&gt;
&lt;p&gt;Let's create a script that starts the SSH agent, adds your key, and gives you control over when it runs. We'll call this script &lt;code&gt;init-ssh&lt;/code&gt;, and we'll stick it somewhere like &lt;code&gt;/usr/local/bin&lt;/code&gt; so it's available from anywhere in your terminal.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Create the script:&lt;/strong&gt;
Open your terminal and create the &lt;code&gt;init-ssh&lt;/code&gt; script:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;sudo&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; nano&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; /usr/local/bin/init-ssh&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Add the script content:&lt;/strong&gt;
Paste the following content into the file:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A9955&quot;&gt;#!/bin/bash&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A9955&quot;&gt;# Start the SSH agent&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;eval&lt;/span&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt; $(&lt;/span&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;ssh-agent&lt;/span&gt;&lt;span style=&quot;color:#569CD6&quot;&gt; -s&lt;/span&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A9955&quot;&gt;# Add the key to the agent&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;ssh-add&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; ~/.ssh/your_key&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#6A9955&quot;&gt;# Optional: Display agent status for peace of mind&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;ssh-add&lt;/span&gt;&lt;span style=&quot;color:#569CD6&quot;&gt; -l&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Make the script executable:&lt;/strong&gt;
Give the script executable permissions:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;sudo&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; chmod&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; +x&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; /usr/local/bin/init-ssh&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id=&quot;how-to-use-the-script&quot;&gt;How to use the script&lt;/h4&gt;
&lt;p&gt;Whenever you want to start your SSH agent for a session, just run:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color:#CE9178&quot;&gt; init-ssh&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will start the agent, add your key, and show you a list of the keys currently loaded in the agent. You've got full control  -  start the agent when you want, stop it when you're done, and enjoy a password-free SSH experience for the duration of that session.&lt;/p&gt;
&lt;h3 id=&quot;optional-stopping-the-ssh-agent&quot;&gt;Optional: Stopping the SSH Agent&lt;/h3&gt;
&lt;p&gt;If you want to stop the SSH agent after you're done with it, you can either let it die when you close your terminal or manually kill it with:&lt;/p&gt;
&lt;pre class=&quot;astro-code dark-plus&quot; style=&quot;background-color:#1E1E1E;color:#D4D4D4; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;eval&lt;/span&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt; $(&lt;/span&gt;&lt;span style=&quot;color:#DCDCAA&quot;&gt;ssh-agent&lt;/span&gt;&lt;span style=&quot;color:#569CD6&quot;&gt; -k&lt;/span&gt;&lt;span style=&quot;color:#D4D4D4&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That way, you get all the convenience of an SSH agent when you need it, without it running indefinitely in the background. You're now in complete control of your SSH setup, and you can keep things secure and efficient, exactly the way you like it.&lt;/p&gt;
&lt;p&gt;Happy SSH'ing!&lt;/p&gt;
</content>
    </entry>
</feed>
