<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Archiwa Bash - soban</title>
	<atom:link href="https://soban.pl/category/bash/feed/" rel="self" type="application/rss+xml" />
	<link>https://soban.pl/category/bash/</link>
	<description>IT, Linux, Servers, Security</description>
	<lastBuildDate>Mon, 02 Mar 2026 14:04:06 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>CrowdSec – Intelligent Linux Server Protection Against Botnets, Brute-Force Attacks and Internet Scanning</title>
		<link>https://soban.pl/crowdsec-linux-server-protection/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Fri, 27 Feb 2026 10:46:55 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=793</guid>

					<description><![CDATA[<p>If you run a Linux server with Nginx, SSH, or WordPress, you probably already know Fail2Ban. It is a solid tool, but it works locally — it blocks only the IP addresses that attacked your server. CrowdSec works in a completely different way. It is a protection system based on shared IP reputation. If thousands [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/crowdsec-linux-server-protection/">CrowdSec – Intelligent Linux Server Protection Against Botnets, Brute-Force Attacks and Internet Scanning</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-large is-resized"><img fetchpriority="high" decoding="async" width="1024" height="685" src="https://soban.pl/wp-content/uploads/2026/02/image-4-1024x685.png" alt="" class="wp-image-789" style="aspect-ratio:1.4949112952561037;width:580px;height:auto" srcset="https://soban.pl/wp-content/uploads/2026/02/image-4-1024x685.png 1024w, https://soban.pl/wp-content/uploads/2026/02/image-4-300x201.png 300w, https://soban.pl/wp-content/uploads/2026/02/image-4-768x514.png 768w, https://soban.pl/wp-content/uploads/2026/02/image-4.png 1174w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>If you run a Linux server with Nginx, SSH, or WordPress, you probably already know <strong>Fail2Ban</strong>. It is a solid tool, but it works locally — it blocks only the IP addresses that attacked <em>your</em> server.</p>



<p><strong>CrowdSec</strong> works in a completely different way. It is a protection system based on shared IP reputation. If thousands of servers worldwide detect a malicious IP address, your server can block it <strong>before an attack even happens</strong>.</p>



<h2 class="wp-block-heading">How Does CrowdSec Work?</h2>



<ul class="wp-block-list">
<li>analyzes system logs (nginx, ssh, wordpress)</li>



<li>detects suspicious behavior</li>



<li>shares attacker IP intelligence with other servers</li>



<li>blocks traffic at the firewall level</li>
</ul>



<p>The result? Most bots and internet scanners never even reach your Nginx server.</p>



<h2 class="wp-block-heading">Installing CrowdSec on Debian / Ubuntu</h2>



<p>CrowdSec installation is very simple and available directly from Debian repositories.</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">apt update
apt install crowdsec</pre></div>



<p>During installation, CrowdSec automatically:</p>



<ul class="wp-block-list">
<li>creates a local API (LAPI)</li>



<li>registers the server in CrowdSec Central API</li>



<li>downloads default security scenarios</li>
</ul>



<h2 class="wp-block-heading">Installing Firewall Bouncer</h2>



<p>CrowdSec detects threats, but it requires an enforcement component — called a <strong>bouncer</strong> — which blocks traffic at the firewall level.</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">apt install crowdsec-firewall-bouncer</pre></div>



<p>By default, the bouncer uses <strong>nftables</strong> and automatically adds blocking rules for malicious IP addresses.</p>



<h2 class="wp-block-heading">Installing Security Collections</h2>



<p>Collections include log parsers and attack detection scenarios.</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">cscli collections install crowdsecurity/nginx
cscli collections install crowdsecurity/wordpress
cscli collections install crowdsecurity/base-http-scenarios
cscli collections install crowdsecurity/sshd</pre></div>



<p>Reload configuration after installation:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">systemctl reload crowdsec</pre></div>



<h2 class="wp-block-heading">Configuring Nginx Logs</h2>



<p>To allow CrowdSec to analyze HTTP traffic, you must specify Nginx log files.</p>



<p>Edit the file:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">nano /etc/crowdsec/acquis.yaml</pre></div>



<p>Add the following configuration:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">filenames:
  - /var/log/nginx/access*.log
  - /var/log/nginx/error*.log
labels:
  type: nginx</pre></div>



<p>Then restart the service:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">systemctl restart crowdsec</pre></div>



<h2 class="wp-block-heading">Verifying CrowdSec Operation</h2>



<p>Service status:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">systemctl status crowdsec</pre></div>



<p>Active bans list:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">cscli decisions list</pre></div>



<p>Operational metrics:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">cscli metrics</pre></div>



<h2 class="wp-block-heading">Final Result</h2>



<p>After proper CrowdSec installation:</p>



<ul class="wp-block-list">
<li>the server automatically blocks known botnets</li>



<li>WordPress attacks and SSH brute-force attempts are stopped at the firewall</li>



<li>Nginx handles significantly less malicious traffic</li>



<li>server CPU and IO usage are noticeably reduced</li>
</ul>



<p>CrowdSec can be considered an <strong>evolution of Fail2Ban</strong> — a system that not only reacts locally but also benefits from global threat intelligence.</p>
<p>Artykuł <a href="https://soban.pl/crowdsec-linux-server-protection/">CrowdSec – Intelligent Linux Server Protection Against Botnets, Brute-Force Attacks and Internet Scanning</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Fail2Ban Nginx Setup &#8211; Block Scanners and Exploits Without Blocking WordPress Admin</title>
		<link>https://soban.pl/fail2ban-nginx-wordpress-setup-2/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Mon, 16 Feb 2026 23:10:10 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=720</guid>

					<description><![CDATA[<p>This guide shows a complete Fail2Ban installation and configuration for Nginx, designed to: block real scanners and exploit attempts (e.g. requests to /.env, /.git, /phpmyadmin, etc.), avoid blocking administrators by accident (common issue when banning only by HTTP errors), ban IP addresses after repeated suspicious activity, use a short ban time (5 minutes) to reduce [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/fail2ban-nginx-wordpress-setup-2/">Fail2Ban Nginx Setup &#8211; Block Scanners and Exploits Without Blocking WordPress Admin</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full"><img decoding="async" width="486" height="747" src="https://soban.pl/wp-content/uploads/2026/02/image-1.png" alt="" class="wp-image-717" srcset="https://soban.pl/wp-content/uploads/2026/02/image-1.png 486w, https://soban.pl/wp-content/uploads/2026/02/image-1-195x300.png 195w" sizes="(max-width: 486px) 100vw, 486px" /></figure>



<h2 class="wp-block-heading">This guide shows a complete Fail2Ban installation and configuration for Nginx, designed to:</h2>



<ul class="wp-block-list">
<li>block real scanners and exploit attempts (e.g. requests to <code>/.env</code>, <code>/.git</code>, <code>/phpmyadmin</code>, etc.),</li>
<li>avoid blocking administrators by accident (common issue when banning only by HTTP errors),</li>
<li>ban IP addresses after repeated suspicious activity,</li>
<li>use a short ban time (5 minutes) to reduce the risk of locking yourself out.</li>
</ul>



<h2 class="wp-block-heading">Why banning by HTTP errors alone can backfire</h2>



<p>Many guides suggest banning by HTTP status codes (4xx/499) only. In real life this often causes self-bans, because modern apps generate bursts of requests (AJAX, admin panels, cache rebuilds), and you can hit error statuses during normal work.</p>



<p>This setup uses a safer approach:</p>



<ul class="wp-block-list">
<li><strong>exploit paths</strong> are always suspicious,</li>
<li><strong>HTTP errors are counted only when the request has no Referer</strong> (typical for scanners),</li>
<li><strong>known bad User-Agents</strong> are counted.</li>
</ul>



<h2 class="wp-block-heading">Step 1: Install Fail2Ban</h2>



<p>Install Fail2Ban:</p>



<pre class="urvanov-syntax-highlighter-plain-tag">apt update
apt install -y fail2ban</pre>



<p>Enable and start the service:</p>



<pre class="urvanov-syntax-highlighter-plain-tag">systemctl enable fail2ban
systemctl start fail2ban</pre>



<p>Verify that it is running:</p>



<pre class="urvanov-syntax-highlighter-plain-tag">fail2ban-client ping
systemctl status fail2ban</pre>



<h2 class="wp-block-heading">Step 2: Create the nginx-secure filter</h2>



<p>Create the filter file:</p>



<pre class="urvanov-syntax-highlighter-plain-tag">nano /etc/fail2ban/filter.d/nginx-secure.conf</pre>



<p>Paste the following configuration:</p>



<pre class="urvanov-syntax-highlighter-plain-tag">[Definition]

failregex =
    # exploit paths
    ^&lt;HOST&gt; - .* "(?:GET|POST|HEAD|PUT|DELETE|OPTIONS|PATCH|PROPFIND|CONNECT) (?:/\.env|/wp-config\.php|/phpinfo\.php|/(?:phpmyadmin|adminer)(?:/|$)|/(?:\.git|\.svn|\.hg)(?:/|$)|/vendor/phpunit/|/cgi-bin/).*" \d{3} .*

    # errors without referer (real scanners)
    ^&lt;HOST&gt; - .* "(?:GET|POST|HEAD|PUT|DELETE|OPTIONS|PATCH|PROPFIND|CONNECT) [^"]*" (?:400|403|404|405|408|413|414|429|444) [^"]* "-" ".*"

    # bad user agents
    ^&lt;HOST&gt; - .* "(?:GET|POST|HEAD|PUT|DELETE|OPTIONS|PATCH|PROPFIND|CONNECT).*" \d{3} .* "(?:[^"]*)" "(?:[^"]*(?:sqlmap|nikto|masscan|zgrab|nmap|acunetix|wpscan|dirbuster|gobuster)[^"]*)"

ignoreregex =</pre>



<h2 class="wp-block-heading">Step 3: Create the nginx-secure jail</h2>



<p>Create the jail configuration file:</p>



<pre class="urvanov-syntax-highlighter-plain-tag">nano /etc/fail2ban/jail.d/nginx-secure.conf</pre>



<p>Paste the following configuration:</p>



<pre class="urvanov-syntax-highlighter-plain-tag">[nginx-secure]
enabled  = true
port     = http,https
filter   = nginx-secure

logpath  = /var/log/nginx/access.log
           /var/log/nginx/access-*.log

findtime = 600
maxretry = 20
bantime  = 300

action   = iptables-multiport[name=nginx-secure, port="http,https"]

ignoreip = 127.0.0.1/8 ::1</pre>



<h2 class="wp-block-heading">Step 4: Restart Fail2Ban</h2>



<pre class="urvanov-syntax-highlighter-plain-tag">fail2ban-server -t
systemctl restart fail2ban</pre>



<h2 class="wp-block-heading">Step 5: Verify firewall integration</h2>



<p>Check that the Fail2Ban chain exists:</p>



<pre class="urvanov-syntax-highlighter-plain-tag">iptables -S | grep f2b-nginx-secure
iptables -L f2b-nginx-secure -n -v</pre>



<h2 class="wp-block-heading">External test</h2>



<p>Run from another machine (exploit path test):</p>



<pre class="urvanov-syntax-highlighter-plain-tag">for i in 1 2 3 4 5; do
  curl -I https://soban.pl/.env
done</pre>



<p>Test &#8220;errors without Referer&#8221; logic (scanner-like request &#8211; no referer header):</p>



<pre class="urvanov-syntax-highlighter-plain-tag">for i in 1 2 3 4 5; do
  curl -sS -o /dev/null -w "%{http_code}\n" https://soban.pl/this-path-should-not-exist-$i
done</pre>



<p>After repeated suspicious requests, the IP address will be banned for 5 minutes.</p>



<h2 class="wp-block-heading">Check banned IPs</h2>



<pre class="urvanov-syntax-highlighter-plain-tag">fail2ban-client status nginx-secure</pre>



<h2 class="wp-block-heading">Unban IP address</h2>



<p>Unban an IP manually:</p>



<pre class="urvanov-syntax-highlighter-plain-tag">fail2ban-client set nginx-secure unbanip YOUR_IP</pre>



<h2 class="wp-block-heading">Summary</h2>



<ul class="wp-block-list">
<li>blocks exploit paths and real scanners,</li>
<li>reduces self-bans by counting HTTP errors only when the Referer is missing,</li>
<li>uses a short 5-minute ban duration,</li>
<li>works with iptables-nft,</li>
<li>easy to test and easy to unban IP addresses.</li>
</ul>
<p>Artykuł <a href="https://soban.pl/fail2ban-nginx-wordpress-setup-2/">Fail2Ban Nginx Setup &#8211; Block Scanners and Exploits Without Blocking WordPress Admin</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Automatic upgrade Debian 12 → Debian 13 with optional PHP and nginx update</title>
		<link>https://soban.pl/upgrade-debian-12-to-13-2/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Mon, 16 Feb 2026 11:15:42 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=709</guid>

					<description><![CDATA[<p>Upgrading Debian from version 12 (bookworm) to 13 (trixie) is an operation that should be performed in a repeatable and predictable way, especially on servers and containers (for example Proxmox LXC or virtual machines). Below you will find a simple guide and ready-to-use commands to download and run the upgrade script. Before running the upgrade: [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/upgrade-debian-12-to-13-2/">Automatic upgrade Debian 12 → Debian 13 with optional PHP and nginx update</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-large is-resized">
<img decoding="async" width="1024" height="682" src="https://soban.pl/wp-content/uploads/2026/02/image-1024x682.png" alt="Debian 12 to Debian 13 upgrade" class="wp-image-707" style="width:551px;height:auto" srcset="https://soban.pl/wp-content/uploads/2026/02/image-1024x682.png 1024w, https://soban.pl/wp-content/uploads/2026/02/image-300x200.png 300w, https://soban.pl/wp-content/uploads/2026/02/image-768x511.png 768w, https://soban.pl/wp-content/uploads/2026/02/image.png 1119w" sizes="(max-width: 1024px) 100vw, 1024px" />
</figure>



<p>Upgrading Debian from version 12 (<strong>bookworm</strong>) to 13 (<strong>trixie</strong>) is an operation that should be performed in a repeatable and predictable way, especially on servers and containers (for example Proxmox LXC or virtual machines). Below you will find a simple guide and ready-to-use commands to download and run the upgrade script.</p>



<p><strong>Before running the upgrade:</strong> create a backup or snapshot. In Proxmox, the best option is <code>vzdump</code> or a snapshot. On bare metal, at minimum back up <code>/etc</code>, applications, and databases.</p>



<ul class="wp-block-list">
<li><strong>Proxmox LXC / VM</strong>: backup using vzdump or create a snapshot.</li>
<li><strong>Server</strong>: backup /etc, /var/www, databases (MySQL/PostgreSQL), and SSL certificates.</li>
</ul>



<p>Script download:</p>



<p><a href="https://soban.pl/bash/upgrade_to_debian13.sh" target="_blank" rel="noopener noreferrer">https://soban.pl/bash/upgrade_to_debian13.sh</a></p>



<h2 class="wp-block-heading">1) Backup before upgrade (examples)</h2>



<p>Example backup in Proxmox (run on Proxmox host, replace CTID/VMID):</p>



<pre class="urvanov-syntax-highlighter-plain-tag">vzdump 101 --mode snapshot --compress zstd --storage local</pre>



<p>Example simple filesystem backup on a server (this does not replace a full snapshot, but it&#8217;s better than nothing):</p>



<pre class="urvanov-syntax-highlighter-plain-tag">tar czf /root/backup_before_upgrade.tar.gz /etc /var/www /root</pre>



<h2 class="wp-block-heading">2) Download the script (wget / curl)</h2>



<p>The easiest way is to use <strong>wget</strong>. If the <code>wget</code> command does not work even though the package is installed, use the full path <code>/usr/bin/wget</code>.</p>



<p><strong>Variant A (standard wget):</strong></p>



<pre class="urvanov-syntax-highlighter-plain-tag">apt update
apt install -y wget
cd /root
wget -O upgrade_to_debian13.sh https://soban.pl/bash/upgrade_to_debian13.sh
chmod +x upgrade_to_debian13.sh</pre>



<p><strong>Variant B (wget with full path – useful if PATH is broken):</strong></p>



<pre class="urvanov-syntax-highlighter-plain-tag">apt update
apt install -y wget
cd /root
/usr/bin/wget -O upgrade_to_debian13.sh https://soban.pl/bash/upgrade_to_debian13.sh
chmod +x upgrade_to_debian13.sh</pre>



<p><strong>Variant C (curl):</strong></p>



<pre class="urvanov-syntax-highlighter-plain-tag">apt update
apt install -y curl
cd /root
curl -fsSL -o upgrade_to_debian13.sh https://soban.pl/bash/upgrade_to_debian13.sh
chmod +x upgrade_to_debian13.sh</pre>



<h2 class="wp-block-heading">3) Script help (parameters)</h2>



<p>Before running the upgrade, display available parameters and usage examples:</p>



<pre class="urvanov-syntax-highlighter-plain-tag">cd /root
./upgrade_to_debian13.sh --help</pre>



<h2 class="wp-block-heading">4) Upgrade Debian 12 → Debian 13 (system only)</h2>



<p>If you are currently running Debian 12 (bookworm) and want to perform a system upgrade:</p>



<pre class="urvanov-syntax-highlighter-plain-tag">cd /root
./upgrade_to_debian13.sh</pre>



<p>The script will create a backup of <code>/etc/apt/sources.list</code>, switch repositories to trixie, run <code>apt update</code> and <code>apt full-upgrade</code>, and finally execute <code>autoremove</code> and <code>autoclean</code>.</p>



<h2 class="wp-block-heading">5) Auto-detect PHP/nginx and update if needed</h2>



<p>If the container or VM is running a web stack and you want the script to automatically detect PHP usage (nginx + <code>fastcgi_pass</code>) and upgrade PHP and nginx if necessary:</p>



<pre class="urvanov-syntax-highlighter-plain-tag">cd /root
./upgrade_to_debian13.sh --auto</pre>



<h2 class="wp-block-heading">6) Force PHP and nginx upgrade (PHP-FPM socket fix)</h2>



<p>If you want to force installation or upgrade of PHP and automatically fix nginx configuration to use the correct PHP-FPM socket:</p>



<pre class="urvanov-syntax-highlighter-plain-tag">cd /root
./upgrade_to_debian13.sh --with-php --with-nginx --php-version 8.2</pre>



<p>This command installs PHP 8.2 (php-fpm and common modules) and replaces old PHP-FPM socket paths in nginx configuration with <code>/run/php/php8.2-fpm.sock</code>. Then it runs <code>nginx -t</code> and reloads or restarts services.</p>



<h2 class="wp-block-heading">7) Already running Debian 13? PHP/nginx only mode</h2>



<p>If the system is already running Debian 13 (trixie) and you only want to upgrade PHP and nginx without modifying system repositories:</p>



<pre class="urvanov-syntax-highlighter-plain-tag">cd /root
./upgrade_to_debian13.sh --php-nginx-only --with-php --with-nginx --php-version 8.2</pre>



<h2 class="wp-block-heading">8) Dry-run mode (test mode)</h2>



<p>If you want to see what the script will do without making any changes:</p>



<pre class="urvanov-syntax-highlighter-plain-tag">cd /root
./upgrade_to_debian13.sh --auto --dry-run</pre>



<h2 class="wp-block-heading">9) Troubleshooting: wget installed but not working</h2>



<p>If <code>apt</code> reports wget is installed but the shell shows <code>command not found</code>, it is usually a PATH issue. The easiest workaround is to use the full path: <code>/usr/bin/wget</code>.</p>



<pre class="urvanov-syntax-highlighter-plain-tag">echo "$PATH"
command -v wget || true
ls -l /usr/bin/wget || true
/usr/bin/wget --version || true</pre>



<h2 class="wp-block-heading">Summary</h2>



<p>This solution provides a convenient way to upgrade Debian 12 → Debian 13 and optionally fix common PHP/nginx issues after upgrade (PHP-FPM socket paths, nginx config testing, and service restart). Always create a backup before upgrading and start by running <code>--help</code> to review available options.</p>



<p>Script: <a href="https://soban.pl/bash/upgrade_to_debian13.sh" target="_blank" rel="noopener noreferrer">https://soban.pl/bash/upgrade_to_debian13.sh</a></p>
<p>Artykuł <a href="https://soban.pl/upgrade-debian-12-to-13-2/">Automatic upgrade Debian 12 → Debian 13 with optional PHP and nginx update</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Dell WD19/WD19S: firmware update on Proxmox/Debian without USB timeouts (fwupd + autosuspend fix)</title>
		<link>https://soban.pl/dell-wd19s-firmware-update-linux-proxmox-debian-usb-timeout-fix/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Sun, 18 Jan 2026 21:06:13 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=670</guid>

					<description><![CDATA[<p>If you’re trying to update the firmware of a Dell WD19/WD19S docking station on Proxmox (or Debian) using fwupdmgr, you may hit the classic Operation timed out error during the Erasing… stage. In practice, the update fails due to USB power management (autosuspend). Below you’ll find a simple, effective fix and a ready-to-run script you [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/dell-wd19s-firmware-update-linux-proxmox-debian-usb-timeout-fix/">Dell WD19/WD19S: firmware update on Proxmox/Debian without USB timeouts (fwupd + autosuspend fix)</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="669" src="https://soban.pl/wp-content/uploads/2026/01/image-1024x669.png" alt="" class="wp-image-667" style="aspect-ratio:1.5306645407436934;width:654px;height:auto" srcset="https://soban.pl/wp-content/uploads/2026/01/image-1024x669.png 1024w, https://soban.pl/wp-content/uploads/2026/01/image-300x196.png 300w, https://soban.pl/wp-content/uploads/2026/01/image-768x502.png 768w, https://soban.pl/wp-content/uploads/2026/01/image.png 1113w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p><br>If you’re trying to update the firmware of a Dell WD19/WD19S docking station on Proxmox (or Debian) using <code>fwupdmgr</code>, you may hit the classic <em>Operation timed out</em> error during the <strong>Erasing…</strong> stage. In practice, the update fails due to USB power management (autosuspend). Below you’ll find a simple, effective fix and a ready-to-run script you can use on a server or laptop.</p>



<h2 class="wp-block-heading">Symptoms</h2>



<p>Most commonly, during a dock firmware update (WD19/WD19S), you’ll see an error similar to:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">failed to write-firmware: failed to erase bank: failed after 5 retries: failed to SetReport: USB error: Operation timed out [-7]</pre></div>



<p>At this point, <code>fwupdmgr</code> may show the WD19S device as <strong>Update State: Failed</strong> or keep reporting <strong>pending activation</strong>, but the flash process never completes.</p>



<h2 class="wp-block-heading">Why does this happen?</h2>



<p>During flashing, the dock performs long-running operations. If the system tries to save power on USB (autosuspend), control transfers can fail. The result is a timeout exactly during the flash bank erase stage (<em>erase bank</em>).</p>



<h2 class="wp-block-heading">Quick fix: disable USB autosuspend during the update</h2>



<p>The simplest solution is to temporarily set autosuspend to <code>-1</code> (disabled). This setting lasts until reboot (unless you make it permanent in the kernel cmdline), but it’s more than enough for the update process.</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">echo -1 &gt; /sys/module/usbcore/parameters/autosuspend</pre></div>



<p>Then run the firmware update:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">fwupdmgr refresh --force
fwupdmgr update</pre></div>



<h2 class="wp-block-heading">After the update: “pending activation” and unplug requirement</h2>



<p>After a successful firmware installation for WD19/WD19S, <code>fwupdmgr</code> often prints the following message:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">The update will continue when the device USB cable has been unplugged.
WD19S is pending activation; use fwupdmgr activate to complete the update.</pre></div>



<p>Do the following in this exact order:</p>



<ul class="wp-block-list">
<li>Unplug the USB-C cable from the dock (from the laptop).</li>



<li>(Optional) Unplug the dock power for 10–15 seconds and plug it back in.</li>



<li>Plug the USB-C cable back in.</li>



<li>Run the activation step:</li>
</ul>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">fwupdmgr activate</pre></div>



<p>Finally, verify the status:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">fwupdmgr get-updates
fwupdmgr get-devices | less</pre></div>



<h2 class="wp-block-heading">Ready-to-use script: install + update + autosuspend disable (with restore)</h2>



<p>Below is a ready-to-run script that:</p>



<ul class="wp-block-list">
<li>installs <code>fwupd</code></li>



<li>refreshes LVFS metadata</li>



<li>temporarily disables USB autosuspend (so WD19S won’t fail with timeouts)</li>



<li>runs firmware updates</li>



<li>restores the previous autosuspend value afterwards (even if the update fails)</li>
</ul>



<p>You can copy the script directly from this article, but if you prefer a faster way, you can download it from:</p>



<p><strong>https://soban.pl/bash/dell_updage.sh</strong></p>



<p>Example download and run:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">cd /root/scripts
curl -fsSL https://soban.pl/bash/dell_updage.sh -o dell_updage.sh
chmod +x dell_updage.sh
./dell_updage.sh</pre></div>



<p>If you want to preview the script before running it:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">curl -fsSL https://soban.pl/bash/dell_updage.sh | less</pre></div>



<p>If you don’t have <code>less</code> installed:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">apt update
apt install -y less</pre></div>



<h2 class="wp-block-heading">Script (full content)</h2>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">#!/bin/bash
set -euo pipefail

# dell upgrade:
# - installs fwupd
# - refreshes metadata
# - runs fwupdmgr update
# - TEMPORARILY disables USB autosuspend to avoid WD19/WD19S timeouts
# - restores autosuspend setting after update

echo "[INFO] Installing fwupd..."
apt update
apt install -y fwupd

echo "[INFO] Refreshing firmware metadata..."
fwupdmgr refresh --force
fwupdmgr get-updates || true

# Save current autosuspend value (if exists)
AUTOSUSPEND_PATH="/sys/module/usbcore/parameters/autosuspend"
OLD_AUTOSUSPEND=""

if [[ -f "$AUTOSUSPEND_PATH" ]]; then
  OLD_AUTOSUSPEND="$(cat "$AUTOSUSPEND_PATH" || true)"
  echo "[INFO] Current usbcore autosuspend: ${OLD_AUTOSUSPEND}"
else
  echo "[WARN] autosuspend sysfs file not found: $AUTOSUSPEND_PATH"
fi

restore_autosuspend() {
  if [[ -f "$AUTOSUSPEND_PATH" &amp;&amp; -n "${OLD_AUTOSUSPEND}" ]]; then
    echo "[INFO] Restoring usbcore autosuspend back to: ${OLD_AUTOSUSPEND}"
    echo "${OLD_AUTOSUSPEND}" &gt; "$AUTOSUSPEND_PATH" || true
  fi
}
trap restore_autosuspend EXIT

# Disable autosuspend to prevent USB timeout during dock firmware erase/write
if [[ -f "$AUTOSUSPEND_PATH" ]]; then
  echo "[INFO] Disabling USB autosuspend (set to -1) to avoid dock update timeouts..."
  echo -1 &gt; "$AUTOSUSPEND_PATH"
fi

read -p "Do you want to update the entire device? (y/n): " answer
if [[ "$answer" == "y" || "$answer" == "Y" ]]; then
  echo "[INFO] Running fwupdmgr update..."
  fwupdmgr update || {
    echo "[ERROR] fwupdmgr update failed."
    echo "[HINT] If this is Dell dock (WD19/WD19S), try: unplug USB-C, replug, then run: fwupdmgr activate"
    exit 1
  }

  echo "[INFO] Update finished."
  echo "[INFO] If you updated a Dell dock and it says 'pending activation':"
  echo "       1) Unplug USB-C cable from the dock"
  echo "       2) (Optional) Unplug dock power for 10 seconds, plug back"
  echo "       3) Run: fwupdmgr activate"
else
  echo "[INFO] Skipping firmware update."
fi

echo "[INFO] Done."</pre></div>



<h2 class="wp-block-heading">Running the script</h2>



<p>The simplest way:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">chmod +x dell_updage.sh
./dell_updage.sh</pre></div>



<h2 class="wp-block-heading">FAQ &amp; tips</h2>



<ul class="wp-block-list">
<li><strong>The update still fails?</strong> Disconnect all peripherals from the dock (monitors/LAN/USB), leave only power and USB-C, do a hard reset of the dock (unplug power for 30s), and try again.</li>



<li><strong>“pending activation” after update</strong> – this is normal for WD19/WD19S. You must unplug USB-C, plug it back in, then run <code>fwupdmgr activate</code>.</li>



<li><strong>Does this update the laptop BIOS?</strong> Not always. <code>fwupdmgr</code> shows “System Firmware” (BIOS/UEFI) separately from the dock. This article focuses on the dock and the USB timeout issue.</li>
</ul>



<h2 class="wp-block-heading">Summary</h2>



<p>If Dell WD19/WD19S firmware updates fail on Proxmox/Debian during the <em>Erasing…</em> stage, in most cases it’s enough to disable USB autosuspend temporarily. The script above does that automatically and restores the previous setting afterwards, so your system keeps working normally.</p>
<p>Artykuł <a href="https://soban.pl/dell-wd19s-firmware-update-linux-proxmox-debian-usb-timeout-fix/">Dell WD19/WD19S: firmware update on Proxmox/Debian without USB timeouts (fwupd + autosuspend fix)</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Dynamic Tmux Window Titles with SSH and Hostname</title>
		<link>https://soban.pl/dynamic-tmux-window-titles-with-ssh-and-hostname/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Tue, 15 Apr 2025 14:55:56 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[tmux]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=629</guid>

					<description><![CDATA[<p>Want your Tmux window titles to automatically show the hostname you connect to via SSH — and restore the local name after you disconnect? This guide will walk you through setting that up step by step. 1. Tmux configuration – ~/.tmux.conf In your Tmux configuration file, set the default shell command to a custom Bash [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/dynamic-tmux-window-titles-with-ssh-and-hostname/">Dynamic Tmux Window Titles with SSH and Hostname</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="1024" height="1024" src="https://soban.pl/wp-content/uploads/2025/04/image-1.png" alt="" class="wp-image-631" style="width:455px;height:auto" srcset="https://soban.pl/wp-content/uploads/2025/04/image-1.png 1024w, https://soban.pl/wp-content/uploads/2025/04/image-1-300x300.png 300w, https://soban.pl/wp-content/uploads/2025/04/image-1-150x150.png 150w, https://soban.pl/wp-content/uploads/2025/04/image-1-768x768.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p><br>Want your Tmux window titles to automatically show the hostname you connect to via SSH — and restore the local name after you disconnect? This guide will walk you through setting that up step by step.</p>



<h2 class="wp-block-heading">1. Tmux configuration – ~/.tmux.conf</h2>



<p>In your Tmux configuration file, set the default shell command to a custom Bash init file (<code>.bash_tmux</code>) that will handle window title updates.</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">set-option -g default-command 'bash --rcfile ~/.bash_tmux'</pre></div>



<h2 class="wp-block-heading">2. Bash init script – ~/.bash_tmux</h2>



<p>This file runs at shell startup inside Tmux. It sets the window name to your local hostname and overrides the <code>ssh</code> command to change the window title dynamically.</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">#!/bin/bash
# ~/.bash_tmux
# Custom Bash init file for Tmux sessions with dynamic tab naming

# Override the default ssh command to dynamically rename the Tmux window
ssh() {
  if [ -n "$TMUX" ]; then
    # Loop through arguments to find the target host (first non-flag argument)
    for arg in "$@"; do
      if [[ "$arg" != -* ]]; then
        if [[ "$arg" == *@* ]]; then
          host="${arg#*@}"  # extract host from user@host
        else
          host="$arg"
        fi
        break
      fi
    done

    # Strip any trailing junk or whitespace
    host="$(echo "$host" | cut -d' ' -f1)"

    # Rename the Tmux window to the SSH target
    [ -n "$host" ] &amp;&amp; tmux rename-window "$host"

    # Save the local hostname to restore later
    local_host="$(hostname -s)"

    # Run the actual SSH command
    command ssh "$@"

    # Restore the original window name after logout
    tmux rename-window "$local_host"
  else
    # Not in Tmux — just run ssh normally
    command ssh "$@"
  fi
}

# Load the user's regular bash configuration
source ~/.bashrc

# On shell start, if in Tmux, set the window name to the current hostname
if [ -n "$TMUX" ]; then
  tmux rename-window "$(hostname -s)"
fi</pre></div>



<h2 class="wp-block-heading">3. Reload Tmux config without restarting</h2>



<p>To apply the changes without restarting the Tmux session, run the following:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">tmux source-file ~/.tmux.conf</pre></div>



<p>To manually reload the current shell with the new <code>.bash_tmux</code> configuration:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">exec bash --rcfile ~/.bash_tmux</pre></div>



<h2 class="wp-block-heading">4. Final result</h2>



<ul class="wp-block-list">
<li>New Tmux windows automatically show the local hostname</li>



<li>When connecting via SSH, the window is renamed to the remote host</li>



<li>When disconnecting, the original local name is restored</li>
</ul>



<p>Clean, readable, and perfect for sysadmins, devops engineers, and Tmux lovers who appreciate automatic order in their terminal tabs 💪</p>
<p>Artykuł <a href="https://soban.pl/dynamic-tmux-window-titles-with-ssh-and-hostname/">Dynamic Tmux Window Titles with SSH and Hostname</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Automatic deletion of files on QNAP drive via SSHFS</title>
		<link>https://soban.pl/automatic-deletion-of-files-on-qnap-drive-via-sshfs/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Fri, 07 Feb 2025 15:05:17 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=584</guid>

					<description><![CDATA[<p>Automation of Disk Space Management in a Linux Environment In today&#8217;s digital world, where data is being accumulated in ever-increasing amounts, managing disk space has become a key aspect of maintaining operational efficiency in systems. In this article, I will present a script that automates the process of managing space on a remote disk mounted [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/automatic-deletion-of-files-on-qnap-drive-via-sshfs/">Automatic deletion of files on QNAP drive via SSHFS</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="501" height="497" src="https://soban.pl/wp-content/uploads/2025/02/image.png" alt="" class="wp-image-574" srcset="https://soban.pl/wp-content/uploads/2025/02/image.png 501w, https://soban.pl/wp-content/uploads/2025/02/image-300x298.png 300w, https://soban.pl/wp-content/uploads/2025/02/image-150x150.png 150w" sizes="auto, (max-width: 501px) 100vw, 501px" /></figure>



<p><br><strong>Automation of Disk Space Management in a Linux Environment</strong></p>



<p>In today&#8217;s digital world, where data is being accumulated in ever-increasing amounts, managing disk space has become a key aspect of maintaining operational efficiency in systems. In this article, I will present a script that automates the process of managing space on a remote disk mounted via SSHFS, particularly useful for system administrators who regularly deal with filling storage media.</p>



<h3 class="wp-block-heading">Prerequisites</h3>



<p>Before starting, ensure that SSHFS and all necessary packages enabling its proper operation are installed on your system. SSHFS allows remote file systems to be mounted via SSH, which is crucial for our script&#8217;s operation. To install SSHFS and the necessary tools, including a package that enables password forwarding (sshpass), use the following command:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">apt-get update
apt-get install sshfs fuse sshpass -y</pre></div>



<h3 class="wp-block-heading">Bash Script for Disk Space Management</h3>



<p>Our Bash script focuses on monitoring and maintaining a defined percentage of free disk space on a remote disk mounted via SSHFS. Here are the script&#8217;s main functions:</p>



<p><strong>Goal Definition:</strong></p>



<p>TARGET_USAGE=70 &#8211; the percentage of disk space we want to maintain as occupied. The script will work to keep at least 30% of the disk space free.</p>



<p><strong>Mount Point and Paths:</strong></p>



<p>MOUNT_POINT=&#8221;/mnt/qnapskorupki&#8221; &#8211; the local directory where the remote disk is mounted. TARGET_DIRS=&#8221;$MOUNT_POINT/up*.soban.pl&#8221; &#8211; the directories where the script will look for files to delete if needed.</p>



<p><strong>Function check_qnap:</strong> This function checks whether the disk is mounted and whether the mount directory is not empty. If there are issues, the script attempts to unmount and remount the disk using sshfs with a password forwarded through sshpass.</p>



<p><strong>File Deletion:</strong> The script monitors disk usage and, if TARGET_USAGE is exceeded, it finds and deletes the oldest files in specified directories until the target level of free space is achieved.</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">#!/bin/bash

TARGET_USAGE=70
MOUNT_POINT="/mnt/qnapskorupki"
TARGET_DIRS="$MOUNT_POINT/up*.soban.pl"

# Function to check and mount SSHFS
function check_qnap {
    local remote_path="/share/MD0_DATA/backup_proxmox/"
    local user_remote="remote_user"
    local remote_host="192.168.1.XX"
    local port=22
    local password='XXXXXXXXXXXXXXXXXXXXXXX'

    # Check if the mounting directory exists and is empty
    if [ ! -d "$MOUNT_POINT" ] || [ -z "$(ls -A $MOUNT_POINT)" ]; then
        echo "Problem: The directory $MOUNT_POINT is missing or empty. Attempting to remount..."

        # Unmount if anything is currently mounted
        if mountpoint -q $MOUNT_POINT; then
            echo "Unmounting $MOUNT_POINT..."
            fusermount -u $MOUNT_POINT
            sleep 5
        fi

        # Remount
        echo "Mounting SSHFS: $user_remote@$remote_host:$remote_path to $MOUNT_POINT..."
        echo $password | sshfs $user_remote@$remote_host:$remote_path $MOUNT_POINT -o password_stdin

        # Check if the mounting was successful
        if mountpoint -q $MOUNT_POINT; then
            echo "QNAP successfully mounted."
        else
            echo "Error: Failed to mount $remote_host:$remote_path to $MOUNT_POINT."
            exit 1
        fi
    fi
}

# Check and mount the disk
check_qnap

# Begin deleting files
current_usage=$(df --output=pcent "$MOUNT_POINT" | tail -n 1 | tr -d '%')
echo "Current usage: $current_usage%"
target_free_space=$((100 - $TARGET_USAGE))

# Continue deleting files until the required free space is achieved
while [[ $current_usage -gt $TARGET_USAGE ]]; do
    # Find the oldest file in the target directories
    oldest_file=$(find $TARGET_DIRS -type f -printf '%T+ %p\n' | sort | head -n 1 | cut -d' ' -f2)

    if [ -z "$oldest_file" ]; then
        echo "No files to delete."
        break
    fi

    # Delete the oldest file
    echo "Deleting file $oldest_file..."
    rm -f "$oldest_file"

    # Check usage again
    current_usage=$(df --output=pcent "$MOUNT_POINT" | tail -n 1 | tr -d '%')
    echo "New usage after deletion: $current_usage%"
done

echo "Target disk usage achieved."</pre></div>



<h3 class="wp-block-heading">Example Script Execution:</h3>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="795" height="164" src="https://soban.pl/wp-content/uploads/2025/02/Zrzut-ekranu-2025-02-07-153719-4.png" alt="script starts working and gradually deletes files" class="wp-image-579" srcset="https://soban.pl/wp-content/uploads/2025/02/Zrzut-ekranu-2025-02-07-153719-4.png 795w, https://soban.pl/wp-content/uploads/2025/02/Zrzut-ekranu-2025-02-07-153719-4-300x62.png 300w, https://soban.pl/wp-content/uploads/2025/02/Zrzut-ekranu-2025-02-07-153719-4-768x158.png 768w" sizes="auto, (max-width: 795px) 100vw, 795px" /></figure>



<p>The script will run until it reaches 70% usage as planned:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="778" height="232" src="https://soban.pl/wp-content/uploads/2025/02/2.jpg" alt="Script runs until reaching 70%" class="wp-image-580" srcset="https://soban.pl/wp-content/uploads/2025/02/2.jpg 778w, https://soban.pl/wp-content/uploads/2025/02/2-300x89.jpg 300w, https://soban.pl/wp-content/uploads/2025/02/2-768x229.jpg 768w" sizes="auto, (max-width: 778px) 100vw, 778px" /></figure>



<h3 class="wp-block-heading" id="block-9d63e003-5e0a-4d60-ae2f-63ff55112faa">Downloading the script and adding it to crontab</h3>



<p id="block-5f75769c-f8fb-4978-ac2d-e8e7868fa484">Of course, the script should be adjusted to meet your specific needs. However, if you want to download it and add it to crontab, follow these steps:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">wget soban.pl/bash/remove_old_files.sh
chmod +x remove_old_files.sh</pre></div>



<p id="block-5f75769c-f8fb-4978-ac2d-e8e7868fa484">If you want to automate the file removal process, for example, at the end of the day, add the following entry to crontab:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">crontab -e</pre></div>



<p id="block-5f75769c-f8fb-4978-ac2d-e8e7868fa484">In this case, the script will run every day at 11:55 PM:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">45 23 * * * /root/scripts/remove_old_files.sh &gt; /dev/null 2&gt;&amp;1</pre></div>



<p id="block-5f75769c-f8fb-4978-ac2d-e8e7868fa484">Make sure to use the correct path to the script.</p>



<h3 class="wp-block-heading">Security and Optimization</h3>



<p>The script uses a password directly in the command line, which can pose a security risk. In practical applications, it is recommended to use more advanced authentication methods, such as SSH keys, which are more secure and do not require a plaintext password in the script. However, in the case of QNAP, we used a password when writing this script.</p>



<h3 class="wp-block-heading">Conclusion</h3>



<p>The presented script is an example of how daily administrative tasks, such as disk space management, can be automated, thus increasing efficiency and reliability. Its implementation in real IT environments can significantly streamline data management processes, especially in situations where quick response to changes in disk usage is critical.</p>
<p>Artykuł <a href="https://soban.pl/automatic-deletion-of-files-on-qnap-drive-via-sshfs/">Automatic deletion of files on QNAP drive via SSHFS</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Expanding Storage Space in Linux: Step-by-Step Guide using LVM and fdisk</title>
		<link>https://soban.pl/expanding-storage-space-in-linux-step-by-step-guide-using-lvm-and-fdisk/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Wed, 13 Nov 2024 19:54:20 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[LVM]]></category>
		<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=529</guid>

					<description><![CDATA[<p>Expanding disk space in Linux virtual machines is a key aspect of server system management. In this article, we show how to effectively increase disk space using LVM and fdisk tools, based on real system data. Preliminary Preparations Before making changes to partitions and volumes, it is important to check the current state of the [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/expanding-storage-space-in-linux-step-by-step-guide-using-lvm-and-fdisk/">Expanding Storage Space in Linux: Step-by-Step Guide using LVM and fdisk</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="558" height="562" src="https://soban.pl/wp-content/uploads/2024/11/image-1.png" alt="" class="wp-image-530" srcset="https://soban.pl/wp-content/uploads/2024/11/image-1.png 558w, https://soban.pl/wp-content/uploads/2024/11/image-1-298x300.png 298w, https://soban.pl/wp-content/uploads/2024/11/image-1-150x150.png 150w" sizes="auto, (max-width: 558px) 100vw, 558px" /></figure>

<!-- Introduction -->
<p>Expanding disk space in Linux virtual machines is a key aspect of server system management. In this article, we show how to effectively increase disk space using LVM and fdisk tools, based on real system data.</p>

<!-- Section 1: Preliminary Preparations -->
<h2>Preliminary Preparations</h2>
<p>Before making changes to partitions and volumes, it is important to check the current state of the disks in the system. We will use the <code>lsblk</code> command to identify available disks and partitions.</p>


<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">lsblk</pre></div>


<!-- Example lsblk output -->
<p>Here is an example of the <code>lsblk</code> command output on a machine:</p>
<pre class="urvanov-syntax-highlighter-plain-tag">NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop0                       7:0    0 55.7M  1 loop /snap/core18/2829
sda                         8:0    0   42G  0 disk
├─sda1                      8:1    0  512M  0 part /boot/efi
├─sda2                      8:2    0    1G  0 part /boot
└─sda3                      8:3    0 40.5G  0 part
  └─ubuntu--vg-ubuntu--lv 253:0    0 78.5G  0 lvm  /
sdb                         8:16   0  350G  0 disk
└─sdb1                      8:17   0   60G  0 part
  └─ubuntu--vg-ubuntu--lv 253:0    0 78.5G  0 lvm  /
sr0                        11:0    1 1024M  0 rom</pre>
<p><!-- Section 2: Creating Snapshots --></p>
<h2>Creating Snapshots</h2>
<p>Before making changes to disk configurations, it is advisable to create a snapshot of the LVM volumes to ensure data can be restored in case of unexpected issues.</p>


<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">lvcreate -L 20G -s -n my_snapshot /dev/ubuntu-vg/ubuntu-lv</pre></div>


<p><!-- Section 3: Modifying Partitions --></p>
<h2>Modifying Partitions</h2>
<p>Next, we proceed to modify the partitions using <code>fdisk</code>. We remove the existing partition and then create a new one that utilizes the entire available space on disk <code>sdb</code>.</p>


<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">fdisk /dev/sdb</pre></div>


<p><!-- Section 4: Saving Changes --></p>
<h2>Saving Changes</h2>
<p>After properly configuring the partitions, we use the <code>w</code> command in <code>fdisk</code> to save the changes and update the partition table.</p>


<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">Command (m for help): w</pre></div>


<p><!-- Section 5: Executing pvscan --></p>
<h2>Executing pvscan</h2>
<p>After modifying the partitions, we execute the <code>pvscan</code> command so the system can update information about available physical volumes.</p>


<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">pvscan</pre></div>


<p><!-- Section 6: Configuring LVM --></p>
<h2>Configuring LVM</h2>
<p>After saving changes to the partition table, we need to update the LVM configuration to include the new disk space. We use the <code>lvextend</code> command with automatic file system resizing.</p>


<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv -r</pre></div>


<p><!-- Summary --></p>
<h2>Summary</h2>
<p>Expanding disk space on a Linux virtual machine enhances performance and the availability of storage space. Thanks to the steps described, managing disk space in systems using LVM becomes simpler and more efficient.</p><p>Artykuł <a href="https://soban.pl/expanding-storage-space-in-linux-step-by-step-guide-using-lvm-and-fdisk/">Expanding Storage Space in Linux: Step-by-Step Guide using LVM and fdisk</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Automating the Backup Process in Proxmox: Practical Crontab Script and Configuration</title>
		<link>https://soban.pl/proxmox-backup-automation-etc/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Tue, 16 Apr 2024 11:54:48 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Proxmox]]></category>
		<category><![CDATA[Security]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=439</guid>

					<description><![CDATA[<p>In today&#8217;s world, where data is becoming increasingly valuable, proper backup management is crucial for the security of information systems. In this article, I present an effective way to automate the backup of key configuration files in Proxmox-based systems using a simple bash script and Crontab configuration. Bash Script for Backup of the /etc Directory [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/proxmox-backup-automation-etc/">Automating the Backup Process in Proxmox: Practical Crontab Script and Configuration</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="1024" height="1024" src="https://soban.pl/wp-content/uploads/2024/04/image.png" alt="" class="wp-image-437" style="width:412px;height:auto" srcset="https://soban.pl/wp-content/uploads/2024/04/image.png 1024w, https://soban.pl/wp-content/uploads/2024/04/image-300x300.png 300w, https://soban.pl/wp-content/uploads/2024/04/image-150x150.png 150w, https://soban.pl/wp-content/uploads/2024/04/image-768x768.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>In today&#8217;s world, where data is becoming increasingly valuable, proper backup management is crucial for the security of information systems. In this article, I present an effective way to automate the backup of key configuration files in Proxmox-based systems using a simple bash script and Crontab configuration.</p>



<h4 class="wp-block-heading">Bash Script for Backup of the <code>/etc</code> Directory</h4>



<p>The <code>/etc</code> file contains critical system configuration files that are essential for the proper functioning of the operating system and various applications. Loss or damage to these files can lead to serious problems. Below, I present an effective script, <code>backup-etc.sh</code>, that allows for the automated backup of this directory:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">#!/bin/bash
date_now=$(date +%Y_%m_%d-%H_%M_%S)
tar --use-compress-program zstd -cf /var/lib/vz/dump/vz-etc-$(hostname)-$date_now.tar.zst /etc/
find /var/lib/vz/dump/ -name vzup1-etc-* -type f -mtime +100 | xargs rm -f</pre></div>



<p>This script performs the following operations:</p>



<ol class="wp-block-list">
<li>Generates the current date and time, which are added to the name of the archive to easily identify individual copies.</li>



<li>Uses the <code>tar</code> program with <code>zstd</code> compression to create an archived and compressed copy of the <code>/etc</code> directory.</li>



<li>Removes archives older than 100 days from the <code>/var/lib/vz/dump/</code> location, thus ensuring optimal disk space management.</li>
</ol>



<h4 class="wp-block-heading">Adding Script to Crontab</h4>



<p>To automate the backup process, the script should be added to crontab. Below is a sample configuration that runs the script daily at 2:40 AM:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># crontab -e
40 2 * * * /root/backup-etc.sh &gt; /dev/null 2&gt;&amp;1</pre></div>



<p>Redirecting output to <code>/dev/null</code> ensures that operations are performed quietly without generating additional output to standard output.</p>



<h4 class="wp-block-heading">Download the Script from soban.pl</h4>



<p>The <code>backup-etc.sh</code> script is also available for download from the soban.pl website. You can download it using the following <code>wget</code> command and immediately save it as <code>/root/backup-etc.sh</code>:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># wget -O /root/backup-etc.sh https://soban.pl/bash/backup-etc.sh &amp;&amp; chmod +x /root/backup-etc.sh</pre></div>



<p>With this simple command, the script is downloaded from the server and granted appropriate executable permissions.</p>



<h4 class="wp-block-heading">Benefits and Modifications</h4>



<p>The <code>backup-etc.sh</code> script is flexible and can be easily modified to suit different systems. It is default placed in the <code>/var/lib/vz/dump/</code> folder, which is a standard backup storage location in Proxmox environments. This simplifies backup management and can be easily integrated with existing backup solutions.</p>



<p>By keeping backups for 100 days, we ensure a balance between availability and disk space management. Old copies are automatically deleted, minimizing the risk of disk overflow and reducing data storage costs.</p>



<h4 class="wp-block-heading">Summary</h4>



<p>Automating backups using a bash script and Crontab is an effective method to secure critical system data. The <code>backup-etc.sh</code> script provides simplicity, flexibility, and efficiency, making it an excellent solution for Proxmox system administrators. I encourage you to adapt and modify this script according to your own needs to provide even better protection for your IT environment.</p>
<p>Artykuł <a href="https://soban.pl/proxmox-backup-automation-etc/">Automating the Backup Process in Proxmox: Practical Crontab Script and Configuration</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Upgrading Apache Cassandra from Version 3.1.15 and Higher to 4.1.x on Ubuntu 20.04.5 LTS: A Comprehensive Guide</title>
		<link>https://soban.pl/upgrading-apache-cassandra-from-version-3-1-15-and-higher-to-4-1-x-on-ubuntu-20-04-5-lts-a-comprehensive-guide/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Mon, 11 Mar 2024 16:39:50 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Cassandra]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nodetool]]></category>
		<category><![CDATA[Patching]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=410</guid>

					<description><![CDATA[<p>Upgrading Apache Cassandra to a newer version is a significant task that database administrators undertake to ensure their systems benefit from new features, enhanced security measures, and improved performance. This guide provides a detailed walkthrough for upgrading Apache Cassandra from version 3.1.15 and higher to the latest 4.1.x version, specifically on Ubuntu 20.04.5 LTS, with [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/upgrading-apache-cassandra-from-version-3-1-15-and-higher-to-4-1-x-on-ubuntu-20-04-5-lts-a-comprehensive-guide/">Upgrading Apache Cassandra from Version 3.1.15 and Higher to 4.1.x on Ubuntu 20.04.5 LTS: A Comprehensive Guide</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1024" height="1024" src="https://soban.pl/wp-content/uploads/2024/03/image.png" alt="" class="wp-image-413" srcset="https://soban.pl/wp-content/uploads/2024/03/image.png 1024w, https://soban.pl/wp-content/uploads/2024/03/image-300x300.png 300w, https://soban.pl/wp-content/uploads/2024/03/image-150x150.png 150w, https://soban.pl/wp-content/uploads/2024/03/image-768x768.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Upgrading Apache Cassandra to a newer version is a significant task that database administrators undertake to ensure their systems benefit from new features, enhanced security measures, and improved performance. This guide provides a detailed walkthrough for upgrading Apache Cassandra from version 3.1.15 and higher to the latest 4.1.x version, specifically on Ubuntu 20.04.5 LTS, with an emphasis on pre-upgrade cleaning operations to manage disk space effectively.</p>



<h3 class="wp-block-heading">Pre-upgrade Preparation</h3>



<p><strong>Backup Configuration Directory:</strong></p>



<p>Before initiating the upgrade, it&#8217;s crucial to back up the Cassandra configuration directory. This precaution allows for a swift restoration of the configuration should any issues arise during the upgrade process. Utilize the following command to create a backup, incorporating the current date into the folder name for easy identification:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># cp -r /etc/cassandra/ /root/cassandra-conf-bkp-$(date +%Y%m%d)</pre></div>



<p><strong>Pre-Cleanup Operations</strong></p>



<p>Preparation is key to a smooth upgrade. Begin with maintenance commands to guarantee data integrity and optimize space usage, especially important for systems with limited disk space.</p>



<p><strong>Scrub Data:</strong></p>



<p>Execute <code>nodetool scrub</code> to clean and reorganize data on disk. Given that this operation may be time-consuming, particularly for databases with large amounts of data or limited disk space, it&#8217;s a critical step for a healthy upgrade process.</p>



<p><strong>Clear Snapshots:</strong></p>



<p>To further manage disk space, use <code>nodetool clearsnapshot</code> to remove existing snapshots, freeing up space for the upgrade process. To delete all snapshots on the node, simply use this method if you&#8217;re running out of space:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># nodetool clearsnapshot --all</pre></div>



<p><strong>Cleanup Data:</strong></p>



<p>Perform a <code>nodetool cleanup</code> to purge unnecessary data. In scenarios where disk space is a premium, it&#8217;s advisable to execute a scrub operation without generating a snapshot to conserve space:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># nodetool scrub --no-snapshot</pre></div>



<h3 class="wp-block-heading">Draining and Stopping Cassandra</h3>



<p><strong>Drain the Node:</strong></p>



<p>Prior to halting the Cassandra service, ensure all data in memory is flushed to disk with <code>nodetool drain</code>.</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># nodetool drain</pre></div>



<p><strong>Stop the Cassandra Service:</strong></p>



<p>Cease the running Cassandra services to proceed with the upgrade safely:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># systemctl stop cassandra.service</pre></div>



<h3 class="wp-block-heading">Upgrading Cassandra</h3>



<p><strong>Update Source List:</strong></p>



<p>Edit the repository sources to point to the new version of Cassandra by adjusting the <code>cassandra.sources.list</code> file:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># echo "deb https://debian.cassandra.apache.org 41x main" &gt; /etc/apt/sources.list.d/cassandra.sources.list</pre></div>



<p><strong>Upgrade Packages:</strong></p>



<p>With the repository sources updated, refresh the package list and upgrade the packages. When executing the <code>apt upgrade</code> command, you can keep pressing Enter as the default option is &#8216;N&#8217; (No):</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># apt update &amp;&amp; apt upgrade</pre></div>



<p><strong>Modify Configuration:</strong></p>



<p>Adjust the Cassandra configuration for version 4.1.x by commenting out or deleting deprecated options:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># for var in thrift_prepared_statements_cache_size_mb start_rpc rpc_port rpc_server_type thrift_framed_transport_size_in_mb request_scheduler; do sed -i "/$var:/s/^/#/" /etc/cassandra/cassandra.yaml; done</pre></div>



<p><strong>Update JAMM Library:</strong></p>



<p>Ensure the Java Agent Memory Manager (JAMM) library is updated to enhance performance:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># sed -i 's|jamm-0.3.0.jar|jamm-0.3.2.jar|g' /etc/cassandra/cassandra-env.sh</pre></div>



<p><strong>Backup and update the JVM options file</strong>:</p>



<p>It&#8217;s a good practice to back up configuration files before making changes. This step renames the existing <code>jvm-server.options</code> file to <code>jvm-server.options.orig</code> as a backup. Then, it copies the <code>jvm.options</code> file to <code>jvm-server.options</code> to apply the standard JVM options for Cassandra servers.</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># cd /etc/cassandra/
# mv jvm-server.options jvm-server.options.orig &amp;&amp; cp -p jvm.options jvm-server.options</pre></div>



<h3 class="wp-block-heading">Optimization and Verification</h3>



<p><strong>Optimize Memory Usage:</strong></p>



<p>Post-upgrade, it&#8217;s beneficial to evaluate and optimize memory usage and swap space to ensure efficient Cassandra operation:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># swapoff -a &amp;&amp; swapon -a</pre></div>



<p><strong>Restart the Cassandra Service:</strong></p>



<p>Apply the new version by restarting the Cassandra service:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># systemctl start cassandra.service</pre></div>



<p><strong>Verify Upgrade:</strong></p>



<p>Confirm the success of the upgrade by inspecting the cluster&#8217;s topology and state, ensuring all nodes are functional:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># nodetool describecluster
# nodetool status</pre></div>



<p>By adhering to this comprehensive guide, database administrators can effectively upgrade Apache Cassandra to version 4.1.x, capitalizing on the latest advancements and optimizations the platform has to offer, while ensuring data integrity and system performance through careful pre-upgrade preparations.</p>



<p><strong>Optimization and Verification</strong></p>



<p>After successfully upgrading Apache Cassandra to version 4.1.x and ensuring the cluster is fully operational, it&#8217;s crucial to conduct post-upgrade maintenance to optimize the performance and security of your database system. This section outlines essential steps and considerations to maintain a healthy and efficient Cassandra environment.<br><br><strong>Monitor Performance and Logs</strong></p>



<p>In the immediate aftermath of the upgrade, closely monitor the system&#8217;s performance, including CPU, memory usage, and disk I/O, to identify any unexpected behavior or bottlenecks. Additionally, review the Cassandra system logs for warnings or errors that may indicate potential issues requiring attention.</p>



<p><strong>Tune and Optimize</strong></p>



<p>Based on the performance monitoring insights, you may need to adjust Cassandra&#8217;s configuration settings for optimal performance. Consider tuning parameters related to JVM options, compaction, and read/write performance, keeping in mind the specific workload and data patterns of your application.</p>



<p><strong>Run nodetool upgradesstables</strong></p>



<p>To ensure that all SSTables are updated to the latest format, execute <code>nodetool upgradesstables</code> on each node in the cluster. This operation will rewrite SSTables that are not already in the current format, which is essential for taking full advantage of the improvements and features in Cassandra 4.1.x (Check the space, and if required, delete all snapshots as shown above.):</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># time nodetool upgradesstables</pre></div>



<p>This process can be resource-intensive and should be scheduled during off-peak hours to minimize impact on live traffic.</p>



<p><strong>Implement Security Enhancements</strong></p>



<p>Cassandra 4.1.x includes several security enhancements. Review the latest security features and best practices, such as enabling client-to-node encryption, node-to-node encryption, and advanced authentication mechanisms, to enhance the security posture of your Cassandra cluster.</p>



<p><strong>Review and Update Backup Strategies</strong></p>



<p>With the new version in place, reassess your backup strategies to ensure they are still effective and meet your recovery objectives. Verify that your backup and restore procedures are compatible with Cassandra 4.1.x and consider leveraging new tools or features that may have been introduced in this release for more efficient data management.</p>
<p>Artykuł <a href="https://soban.pl/upgrading-apache-cassandra-from-version-3-1-15-and-higher-to-4-1-x-on-ubuntu-20-04-5-lts-a-comprehensive-guide/">Upgrading Apache Cassandra from Version 3.1.15 and Higher to 4.1.x on Ubuntu 20.04.5 LTS: A Comprehensive Guide</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Improving encryption on old red hat 5 by new Oracle Linux 7 using apache mod_proxy</title>
		<link>https://soban.pl/improving-encryption-on-old-red-hat-5-by-new-oracle-linux-7-using-apache-mod_proxy/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Sat, 06 Nov 2021 13:54:17 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Oracle Linux]]></category>
		<category><![CDATA[Proxy]]></category>
		<category><![CDATA[Red Hat 5]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SSL]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=308</guid>

					<description><![CDATA[<p>There are situations when we need to increase the encryption level on the old system &#8211; according to the PCI audit requirements. However, the old system is no longer supported, so updating the encryption level is not possible. This is not a recommended solution, because we should try to transfer the application to a new [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/improving-encryption-on-old-red-hat-5-by-new-oracle-linux-7-using-apache-mod_proxy/">Improving encryption on old red hat 5 by new Oracle Linux 7 using apache mod_proxy</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>There are situations when we need to increase the encryption level on the old system &#8211; according to the PCI audit requirements. However, the old system is no longer supported, so updating the encryption level is not possible. This is not a recommended solution, because we should try to transfer the application to a new system. After all, when we have little time, it is possible to hide the old version of the system and allow only the new machine to move to it. In this particular example, we will use mod_proxy as a proxy to redirect traffic to the old machine, while using iptables we will only allow communication with the new machine. It is not a recommended solution, but it works and I would like to present it here. The systems that I will be basing on in this example are the old <strong>red hat 5</strong> and the new <strong>oracle linux 7</strong>. Recently, it has become very important to use a minimum of <strong>tls 1.2</strong> and none below for banking transactions. Let&#8217;s start with the proxy server configuration <strong>oracle linux 7</strong>.</p>



<p>As of this writing, the addressing is as follows:<br><strong>new_machine</strong> IP: <strong>10.10.14.100</strong><br><strong>old_machine</strong> IP: <strong>10.10.14.101</strong><br>Traffic will be routed on port 443 from new_machine to old_machine.</p>



<p>Before we go to proxy configuration, please make sure there are network transitions from new_machine (10.10.14.100) to old_machine (10.10.14.101) to port 443. You can read how to verify network connections here: <strong><a href="https://soban.pl/check-network-connection-and-open-tcp-port-via-netcat/" target="_blank" rel="noreferrer noopener">check network connection and open tcp port via netcat</a></strong>.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="544" height="51" src="https://soban.pl/wp-content/uploads/2021/11/image-13.png" alt="" class="wp-image-309" srcset="https://soban.pl/wp-content/uploads/2021/11/image-13.png 544w, https://soban.pl/wp-content/uploads/2021/11/image-13-300x28.png 300w" sizes="auto, (max-width: 544px) 100vw, 544px" /></figure>



<p>We go to the installation of apache and mod_proxy:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># yum install httpd mod_proxy</pre></div>



<p>After installing apache, go to the edition:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># vi /etc/httpd/conf.d/ssl.conf</pre></div>



<p>Below are the news on the check level, what are the updates, and ip on the next service update:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">&lt;VirtualHost _default_:443&gt;
SSLProtocol -all +TLSv1.2
SSLCipherSuite ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:!NULL:!RC4:!RC2:!DES:!3DES:!SHA:!SHA256:!SHA384:!MD5+HIGH:+MEDIUM:!KRB5
#…
&lt;IfModule mod_proxy.c&gt;
SSLProxyProtocol all
SSLProxyEngine on
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
ProxyRequests On
    &lt;Proxy *&gt;
        Require all granted
    &lt;/Proxy&gt;
    # backend server and forwarded path
    ProxyPass / https://10.10.14.101/
    ProxyPassReverse / https://10.10.14.101/
&lt;/IfModule&gt;
&lt;/VirtualHost&gt;</pre></div>



<p>In order to verify the correctness of apache configuration, you can issue a command that will check it:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># service httpd configtest</pre></div>



<p>If the apache configuration is correct, we can proceed to reloading apache:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># service httpd restart</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="621" height="50" src="https://soban.pl/wp-content/uploads/2021/11/image-14.png" alt="" class="wp-image-310" srcset="https://soban.pl/wp-content/uploads/2021/11/image-14.png 621w, https://soban.pl/wp-content/uploads/2021/11/image-14-300x24.png 300w" sizes="auto, (max-width: 621px) 100vw, 621px" /></figure>



<p>At this point, we have a configured proxy connection. Before we move on to limiting traffic with iptables, I suggest you go to the site &#8211; with the new mod_proxy configured and test if everything is working properly and if there are any problems with the application.</p>



<p>Once everything is working fine, the network transitions are there, we can go to the iptables configuration for red hat 5. Let&#8217;s start by checking the system version:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># cat /etc/redhat-release</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="663" height="48" src="https://soban.pl/wp-content/uploads/2021/11/image-15.png" alt="" class="wp-image-311" srcset="https://soban.pl/wp-content/uploads/2021/11/image-15.png 663w, https://soban.pl/wp-content/uploads/2021/11/image-15-300x22.png 300w" sizes="auto, (max-width: 663px) 100vw, 663px" /></figure>



<p>Now we are going to prepare iptables so that the network traffic is available on port 443 from the new_machine (10.10.14.100). To do this, edit the file <strong>/etc/sysconfig/iptables</strong>:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp --dport 443 -s 10.10.14.100 -j ACCEPT
-A INPUT -p tcp --dport 443 -j DROP
-A INPUT -p tcp --dport 80 -j DROP
-A INPUT -j ACCEPT
COMMIT</pre></div>



<p>After iptables settings are correct, we can reload the service:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># /etc/init.d/iptables restart</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="886" height="153" src="https://soban.pl/wp-content/uploads/2021/11/image-16.png" alt="" class="wp-image-313" srcset="https://soban.pl/wp-content/uploads/2021/11/image-16.png 886w, https://soban.pl/wp-content/uploads/2021/11/image-16-300x52.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-16-768x133.png 768w" sizes="auto, (max-width: 886px) 100vw, 886px" /></figure>



<p>In this way, we managed to cover up the weak encryption by proxying and diverting traffic to the new machine. This is not a recommended solution and you should try to transfer the application to a new environment compatible with the new system. However, in crisis situations, we can use this solution. Network traffic is not allowed by other IP addresses, so scanners will not be able to detect weak encryption on the old machine, and users using the old environment will not be able to use it. This does not change the fact that weak encryption is still set in the old environment and needs to be corrected. The example I gave is for the old <strong>red hat 5</strong> and the new <strong>oracle linux 7</strong>, but it can be assumed that a similar solution and configuration is possible for other versions of the system.</p>
<p>Artykuł <a href="https://soban.pl/improving-encryption-on-old-red-hat-5-by-new-oracle-linux-7-using-apache-mod_proxy/">Improving encryption on old red hat 5 by new Oracle Linux 7 using apache mod_proxy</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
