<?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 Debian - soban</title>
	<atom:link href="https://soban.pl/category/debian/feed/" rel="self" type="application/rss+xml" />
	<link>https://soban.pl/category/debian/</link>
	<description>IT, Linux, Servers, Security</description>
	<lastBuildDate>Thu, 26 Feb 2026 13:49:39 +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>Simplified Proxmox VE 8 Installation on Debian 12 Bookworm</title>
		<link>https://soban.pl/simplified-proxmox-ve-8-installation-on-debian-12-bookworm/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Fri, 09 Feb 2024 11:36:05 +0000</pubDate>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Proxmox]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=356</guid>

					<description><![CDATA[<p>Proxmox VE is a comprehensive, open-source server management platform that seamlessly integrates KVM hypervisor and LXC containers. Today, we present a streamlined process for installing Proxmox VE 8 on Debian 12 Bookworm, based on the official guidance from the Proxmox VE Installation Guide. Prerequisites Installation Scripts We&#8217;ve divided the installation into two scripts. The first [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/simplified-proxmox-ve-8-installation-on-debian-12-bookworm/">Simplified Proxmox VE 8 Installation on Debian 12 Bookworm</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p><strong>Proxmox VE</strong> is a comprehensive, open-source server management platform that seamlessly integrates KVM hypervisor and LXC containers. Today, we present a streamlined process for installing Proxmox VE 8 on Debian 12 Bookworm, based on the official guidance from the <a href="https://pve.proxmox.com/wiki/Install_Proxmox_VE_on_Debian_12_Bookworm">Proxmox VE Installation Guide</a>.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



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



<ul class="wp-block-list">
<li>A fresh <strong>Debian 12 Bookworm</strong> installation.</li>



<li>A user with sudo privileges.</li>



<li>Internet connectivity.</li>
</ul>



<h2 class="wp-block-heading">Installation Scripts</h2>



<p>We&#8217;ve divided the installation into two scripts. The first script prepares your system and installs the <strong>Proxmox VE</strong> kernel. The second script continues the process after a system reboot, installing the remaining <strong>Proxmox VE</strong> packages.</p>



<p>Remember, all these commands need to be executed from the root user level, so:</p>



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



<h3 class="wp-block-heading">First Part: System Preparation and Kernel Installation</h3>



<p>Start by downloading the first script which prepares your system and installs the <strong>Proxmox VE</strong> kernel:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># wget https://soban.pl/bash/install-proxmox-part1.sh
# chmod +x install-proxmox-part1.sh</pre></div>



<p>Run the script with the following command:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># ./install-proxmox-part1.sh</pre></div>



<p>Here is the content of the script:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">#!/bin/bash
# The script is an integral part of the article available at (part 1/2)
# https://soban.pl/simplified-proxmox-ve-8-installation-on-debian-12-bookworm/

# Introduction message
echo "Starting the setup for Proxmox VE installation on Debian Bookworm..."

# Display available network interfaces and their IP addresses
echo "Available network interfaces and IP addresses:"
ip -br -c a

# Retrieve the current hostname
CURRENT_HOSTNAME=$(hostname)

# Retrieve the current IP address
CURRENT_IP_ADDRESS=$(hostname -I | awk '{print $1}')

# Set up hostname
echo "Please enter the hostname for your Proxmox server (Press Enter to keep current: $CURRENT_HOSTNAME):"
read HOSTNAME
if [ -z "$HOSTNAME" ]; then
    HOSTNAME=$CURRENT_HOSTNAME
fi

# Set up IP address
echo "Based on the list above, please enter the IP address for your Proxmox server (Press Enter to keep current: $CURRENT_IP_ADDRESS):"
read IPADDRESS
if [ -z "$IPADDRESS" ]; then
    IPADDRESS=$CURRENT_IP_ADDRESS
fi

hostnamectl set-hostname "$HOSTNAME"

# Backup and configure /etc/hosts
cp /etc/hosts /etc/hosts.backup
cat &lt;&lt;EOF &gt; /etc/hosts
127.0.0.1       localhost
$IPADDRESS      $HOSTNAME

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
EOF

# Backup existing sources.list and prepare Proxmox VE repository
cp /etc/apt/sources.list /etc/apt/sources.list.backup
echo "deb [arch=amd64] http://download.proxmox.com/debian/pve bookworm pve-no-subscription" &gt; /etc/apt/sources.list.d/pve-install-repo.list

# Add the Proxmox VE repository key
wget https://enterprise.proxmox.com/debian/proxmox-release-bookworm.gpg -O /etc/apt/trusted.gpg.d/proxmox-release-bookworm.gpg
echo "Verifying the GPG key..."
sha512sum /etc/apt/trusted.gpg.d/proxmox-release-bookworm.gpg | grep '7da6fe34168adc6e479327ba517796d4702fa2f8b4f0a9833f5ea6e6b48f6507a6da403a274fe201595edc86a84463d50383d07f64bdde2e3658108db7d6dc87'
if [ $? -ne 0 ]; then
    echo "GPG key verification failed. Aborting."
    exit 1
fi

# Update and upgrade the system
apt update &amp;&amp; apt full-upgrade -y

# Install the Proxmox VE kernel
apt install proxmox-default-kernel -y

# Install Proxmox VE and other necessary packages
apt install proxmox-ve postfix open-iscsi chrony -y

echo "Kernel installation completed. The system will now reboot. After rebooting, continue with the second part of the script."
reboot</pre></div>



<p>After running the first script, your system will reboot. At this stage, you may encounter a few dialogs from the system, which are part of the normal package configuration steps. For this simplified installation, you can accept the default options by pressing Enter.</p>



<h3 class="wp-block-heading">Screenshots during Installation</h3>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="221" src="https://soban.pl/wp-content/uploads/2024/02/grub-proxmox_installation-2-1024x221.png" alt="The selection of GRUB installation configuration." class="wp-image-374" srcset="https://soban.pl/wp-content/uploads/2024/02/grub-proxmox_installation-2-1024x221.png 1024w, https://soban.pl/wp-content/uploads/2024/02/grub-proxmox_installation-2-300x65.png 300w, https://soban.pl/wp-content/uploads/2024/02/grub-proxmox_installation-2-768x166.png 768w, https://soban.pl/wp-content/uploads/2024/02/grub-proxmox_installation-2.png 1353w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p><strong>GRUB Configuration</strong> &#8211; A new version of the <strong>GRUB bootloader</strong> configuration file is available. It&#8217;s recommended to keep the local version currently installed unless you are aware of the changes. As with the previous dialogs, pressing Enter will select the default action.</p>



<figure class="wp-block-image size-full"><img decoding="async" width="678" height="490" src="https://soban.pl/wp-content/uploads/2024/02/postfix-proxmox_installation.png" alt="The selection of postfix installation configuration." class="wp-image-357" srcset="https://soban.pl/wp-content/uploads/2024/02/postfix-proxmox_installation.png 678w, https://soban.pl/wp-content/uploads/2024/02/postfix-proxmox_installation-300x217.png 300w" sizes="(max-width: 678px) 100vw, 678px" /></figure>



<p><strong>Postfix Configuration</strong> &#8211; This dialog appears when installing the postfix package, which is a mail transport agent. The default option &#8220;Internet Site&#8221; is suitable for most cases. Pressing Enter accepts this configuration.</p>



<figure class="wp-block-image size-full"><img decoding="async" width="642" height="344" src="https://soban.pl/wp-content/uploads/2024/02/system_FQND-proxmox_installation.png" alt="Setting the system mail name." class="wp-image-358" srcset="https://soban.pl/wp-content/uploads/2024/02/system_FQND-proxmox_installation.png 642w, https://soban.pl/wp-content/uploads/2024/02/system_FQND-proxmox_installation-300x161.png 300w" sizes="(max-width: 642px) 100vw, 642px" /></figure>



<p><strong>System Mail Name</strong> &#8211; Here you specify the FQDN (Fully Qualified Domain Name) for the system mail. The default value is usually adequate unless you have a specific domain name for your server. Again, pressing Enter will continue with the default configuration.</p>



<p>There might be issues encountered towards the end of the first script installation, such as:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">Errors were encountered while processing:
 ifupdown2
 pve-manager
 proxmox-ve
E: Sub-process /usr/bin/dpkg returned an error code (1)</pre></div>



<p>However, the second part of the script, executed after the reboot, addresses these problems.<br>After a successful reboot of the machine, log into the system and proceed to the second script.</p>



<h3 class="wp-block-heading">Second Part: Completing Proxmox VE Installation</h3>



<p>After your system has rebooted, proceed with downloading the second script:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># wget https://soban.pl/bash/install-proxmox-part2.sh
# chmod +x install-proxmox-part2.sh</pre></div>



<p>Execute the second part of the installation with the command:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># ./install-proxmox-part2.sh</pre></div>



<p>This is the content of the second script:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">#!/bin/bash
# The script is an integral part of the article available at (part 2/2)
# https://soban.pl/simplified-proxmox-ve-8-installation-on-debian-12-bookworm/

# Introduction message
echo "Continuing Proxmox VE installation after reboot..."

# Install upgrade
apt upgrade -y

# Optional: Remove the Debian default kernel
apt remove linux-image-amd64 'linux-image-6.1*' -y
update-grub

# Optionally remove the os-prober package
apt remove os-prober -y

# Clean up installation repository entry
rm /etc/apt/sources.list.d/pve-install-repo.list

# Retrieve the server's IP address for the Proxmox web interface link
IP_ADDRESS=$(hostname -I | awk '{print $1}')
echo "Proxmox VE installation completed."
echo "You can now connect to the Proxmox VE web interface using:"
echo "https://$IP_ADDRESS:8006"
echo "Please log in using the 'root' username and your root password."</pre></div>



<p>Once the second script completes, you will be able to access the Proxmox VE web interface using the URL displayed at the script&#8217;s conclusion. Log in with the &#8216;root&#8217; username and your root password.</p>



<p>Upon loading the page, you may encounter a certificate trust error &#8211; this is normal at this stage, and you can safely accept that it is unsafe and proceed to access the page for managing Proxmox. If you don&#8217;t know the root password, you can reset it by executing &#8216;<code><strong>passwd</strong></code>&#8216; as root. Good luck!</p>
<p>Artykuł <a href="https://soban.pl/simplified-proxmox-ve-8-installation-on-debian-12-bookworm/">Simplified Proxmox VE 8 Installation on Debian 12 Bookworm</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Proxy through nginx frontend to the second virtual server wordpress</title>
		<link>https://soban.pl/proxy-through-nginx-frontend-to-the-second-virtual-server-wordpress/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Sun, 07 Nov 2021 11:48:33 +0000</pubDate>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[Proxy]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Wordpress]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=315</guid>

					<description><![CDATA[<p>In a situation where we have one public IP address and we have many domains directed to that IP address, it is worth considering spreading the traffic to other servers. Proxmox, which allows you to create a pair of virtual machines, is perfect in such a situation. In my case, each virtual machine is separated [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/proxy-through-nginx-frontend-to-the-second-virtual-server-wordpress/">Proxy through nginx frontend to the second virtual server wordpress</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In a situation where we have one public IP address and we have many domains directed to that IP address, it is worth considering spreading the traffic to other servers. Proxmox, which allows you to create a pair of virtual machines, is perfect in such a situation. In my case, each virtual machine is separated and the traffic is broken down by nginx, which distributes the traffic to other servers. The virtual machine on my website will redirect traffic, I have the IP address for wordpress: <strong>10.10.11.105 </strong>on port <strong>80</strong>. In this case, no encryption is required, but the frontend itself, which manages the traffic, will present itself with encryption and security on port <strong>443</strong>.</p>



<p>Two machines with the following configuration will participate throughout the process:<br><strong>up-page</strong> IP: <strong>10.10.14.200</strong><br><strong>soban-pl</strong> IP: <strong>10.10.11.105</strong></p>



<p>So let&#8217;s move on to the frontend that distributes traffic to other machines.<br>The frontend is done by linux debian 11 (bullseye), in addition, I have the following entry in the repository (<strong>/etc/apt/sources.list</strong>):</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">#...
deb http://nginx.org/packages/debian/ bullseye nginx
deb-src http://nginx.org/packages/debian/ bullseye nginx</pre></div>



<p>To install nginx, run the following commands:</p>



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



<p>You should make sure that the traffic from the frontend has the appropriate port 80 transitions. You can read how to check the network transitions 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="469" height="154" src="https://soban.pl/wp-content/uploads/2021/11/image-18.png" alt="Screenshot of a terminal window showing a successful telnet connection to the IP address 10.10.11.105 on port 80, followed by the user exiting the telnet session with the 'quit' command." class="wp-image-317" srcset="https://soban.pl/wp-content/uploads/2021/11/image-18.png 469w, https://soban.pl/wp-content/uploads/2021/11/image-18-300x99.png 300w" sizes="auto, (max-width: 469px) 100vw, 469px" /></figure>



<p>The configuration of the frontend that distributes the traffic is as follows (<strong>/etc/nginx/conf.d/soban.pl.ssl.conf</strong>):</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">upstream soban-pl-webservers {
    server 10.10.11.105:80;
}

server {
    if ($host = www.soban.pl) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = soban.pl) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        listen 80;
        server_name soban.pl www.soban.pl;
        return 301 https://soban.pl$request_uri;
}

server {
    listen 443 ssl http2;
    server_name  www.soban.pl;
    ssl_certificate /etc/letsencrypt/live/www.soban.pl/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/www.soban.pl/privkey.pem; # managed by Certbot
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;
    ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
    return 301 https://soban.pl$request_uri;
}

server {
    listen 443 ssl http2;
    server_name  soban.pl _;
    ssl_certificate /etc/letsencrypt/live/soban.pl/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/soban.pl/privkey.pem; # managed by Certbot
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;
    ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
}

    location / {
        access_log /var/log/nginx/access-soban.pl.log;
        error_log /var/log/nginx/error-soban.pl.log;
        proxy_pass http://soban-pl-webservers;
        proxy_redirect https://soban-pl-webservers http://soban-pl-webservers;
        expires off;

        proxy_read_timeout       3500;
        proxy_connect_timeout    3250;

        proxy_set_header   X-Real-IP          $remote_addr;
        proxy_set_header   Host               $host;
        proxy_set_header   X-Forwarded-For    $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto  https;
        proxy_set_header   SSL_PROTOCOL $ssl_protocol;
        proxy_set_header   SSL_CLIENT_CERT $ssl_client_cert;
        proxy_set_header   SSL_CLIENT_VERIFY $ssl_client_verify;
        proxy_set_header   SSL_SERVER_S_DN $ssl_client_s_dn;

                proxy_set_header X-Scheme $scheme;
                proxy_ssl_session_reuse off;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
    }
      location ~ ^/(wp-admin|wp-login\.php) {
            auth_basic "Restricted";
            auth_basic_user_file /etc/nginx/conf.d/htpasswd;
           proxy_pass http://soban-pl-webservers;
           proxy_redirect https://soban-pl-webservers http://soban-pl-webservers;
           expires off;
           proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
           proxy_set_header        Host            $host;
           proxy_set_header        X-Real-IP       $remote_addr;
           proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      }

}</pre></div>



<p>Configuration of the above-mentioned wordpress, additional authorization is also set when you try to log in to wp-admin, you can read about it here: <strong><a href="https://soban.pl/more-security-wp-admin-in-nginx/" target="_blank" rel="noreferrer noopener">More security wp-admin in nginx</a></strong>. </p>



<p>In the next step, check if the nginx configuration is correct by: </p>



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



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="808" height="76" src="https://soban.pl/wp-content/uploads/2021/11/image-17.png" alt="Terminal output displaying a successful nginx configuration test with the messages: 'nginx: the configuration file /etc/nginx/nginx.conf syntax is ok' and 'nginx: configuration file /etc/nginx/nginx.conf test is successful'." class="wp-image-316" srcset="https://soban.pl/wp-content/uploads/2021/11/image-17.png 808w, https://soban.pl/wp-content/uploads/2021/11/image-17-300x28.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-17-768x72.png 768w" sizes="auto, (max-width: 808px) 100vw, 808px" /></figure>



<p>If everything is fine, restart nginx:</p>



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



<p>In a virtual machine with nginx it should also be installed. This is the same as debian linux 11 (bullseye), so the respository should look like this:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">#...
deb http://nginx.org/packages/debian/ bullseye nginx
deb-src http://nginx.org/packages/debian/ bullseye nginx</pre></div>



<p>Just installing nginx looks the same as on a machine that acts as a proxy.</p>



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



<p>All configuration is in <strong>/etc/nginx/conf.d/soban.pl.conf</strong>:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">server {
    listen   80;

   client_max_body_size 20M;

    server_name soban.pl www.soban.pl;
    access_log /var/log/nginx/access-soban.pl.log; #access logi
    error_log /var/log/nginx/error-soban.log; # error logi
    port_in_redirect off;
    set_real_ip_from  10.10.11.105;
    real_ip_header    X-Forwarded-For;
    real_ip_recursive on;
       root /home/produkcja/wordpress/;
       index index.html index.php;

if ($host ~* ^www\.(.*))
{
    set $host_without_www $1;
    rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
}

    error_page 404 /index.php;


        location ~ \.php$ {
                root /home/produkcja/wordpress/; # dir where is wordpress
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php/php-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        }

        location / {
                try_files $uri $uri/ /index.php?$args;
        }
        location = /sitemap.xml {
                rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last;
                rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last;
                rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last;
                rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;
       }

location = /favicon.ico {
  return 204;
  access_log     off;
  log_not_found  off;
}

location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
        }location ~* \.(pdf)$ {
expires 30d;
}

}</pre></div>



<p>Also in this case, check the correctness of the nginx service configuration:</p>



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



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="802" height="66" src="https://soban.pl/wp-content/uploads/2021/11/image-19.png" alt="" class="wp-image-318" srcset="https://soban.pl/wp-content/uploads/2021/11/image-19.png 802w, https://soban.pl/wp-content/uploads/2021/11/image-19-300x25.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-19-768x63.png 768w" sizes="auto, (max-width: 802px) 100vw, 802px" /></figure>



<p>Everything looks fine, so let&#8217;s move on to restarting the service:</p>



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



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="806" height="71" src="https://soban.pl/wp-content/uploads/2021/11/image-20.png" alt="" class="wp-image-319" srcset="https://soban.pl/wp-content/uploads/2021/11/image-20.png 806w, https://soban.pl/wp-content/uploads/2021/11/image-20-300x26.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-20-768x68.png 768w" sizes="auto, (max-width: 806px) 100vw, 806px" /></figure>



<p>If the whole configuration was done correctly, the page should be directed without encrypted traffic to the virtual machine with wordpress. A wordpress service with nginx is not the only one that can be hosted or proxied. We can direct traffic from nginx to e.g. jboss, apacha and all other web services. Of course, this requires a corresponding modification of the configuration presented above, but the general outline of the concept as an nginx proxy has been presented. You should also remember about the appropriate configuration of keys and certificates. In my case let&#8217;s encrypt works perfectly for this.</p>
<p>Artykuł <a href="https://soban.pl/proxy-through-nginx-frontend-to-the-second-virtual-server-wordpress/">Proxy through nginx frontend to the second virtual server wordpress</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Increasing the security of the ssh service</title>
		<link>https://soban.pl/increasing-the-security-of-the-ssh-service/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Fri, 05 Nov 2021 15:06:21 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Kali]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[ssh]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=305</guid>

					<description><![CDATA[<p>Nowadays, many bots or hackers look for port 22 on servers and try to log in. Usually, the login attempt is made as the standard linuxe root user. In this short article, I will describe how to create a user that will be able to log in as root and change the default ssh port [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/increasing-the-security-of-the-ssh-service/">Increasing the security of the ssh service</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Nowadays, many bots or hackers look for port 22 on servers and try to log in. Usually, the login attempt is made as the standard linuxe root user. In this short article, I will describe how to create a user that will be able to log in as root and change the default ssh port 22 to 2222. Let&#8217;s go:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">useradd -m soban -s /bin/bash</pre></div>



<p>This way we created the user &#8216;soban&#8217; and assigned it the default shell &#8216;/bin/bash&#8217;. </p>



<p>We still need to set a password for the user &#8216;soban&#8217;:</p>



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



<p>In the next step, let&#8217;s add it to &#8216;/etc/sudoers&#8217; so that it can become root. Keep in mind that once the user can get root, he will be able to do anything on the machine!</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># vi /etc/sudoers</pre></div>



<p>Please add this entry below:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">#user can made sudo on root (sudo su -)
soban ALL=(ALL) NOPASSWD: ALL</pre></div>



<p>How can we test whether the user has the ability to log in as root? Nothing easier, first we&#8217;ll switch to the user we just created:</p>



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



<p>To list the possible sudo commands, just type the command:</p>



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



<p>Finally, to confirm whether it is possible to log in as root, you should issue the command:</p>



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



<p>Now that we have a root user ready, let&#8217;s try disabling ssh logon directly and change the default port. To do this, go to the default configuration of the ssh service, which is located in &#8216;/etc/ssh/sshd_config&#8217;:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># vi /etc/ssh/sshd_config</pre></div>



<p>We are looking for a line containing &#8216;Port&#8217; &#8211; it can be hashed, so it should be unhashed and &#8216;PermitRootLogin&#8217;. Then set them as below:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">Port 2222
PermitRootLogin no</pre></div>



<p>In this way, we changed the default port 22 to 2222 and disallowed the possibility of logging in directly to the root user. However, the ssh service still needs to be reloaded, in debian or kali linux we do it like this:</p>



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



<p>In this way, we have managed to create a user who can safely log into the ssh service and become root. In addition, after changing the port, we will not go out on port 22 scans, which by default is set and scanned by a potential burglar. Installing the fail2ban service is also a very good improvement in security.</p>
<p>Artykuł <a href="https://soban.pl/increasing-the-security-of-the-ssh-service/">Increasing the security of the ssh service</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>iftop as a good network traffic monitoring tool</title>
		<link>https://soban.pl/iftop-as-a-good-network-traffic-monitoring-tool/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Thu, 04 Nov 2021 15:47:42 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[iftop]]></category>
		<category><![CDATA[Kali]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Security]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=285</guid>

					<description><![CDATA[<p>iftop is a command-line tool for real-time network bandwidth monitoring. It displays a continuously updated list of network connections along with the amount of data transferred between them. Connections are shown in a table format and can be sorted by bandwidth usage. iftop provides various filtering options, allowing you to limit the output to specific [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/iftop-as-a-good-network-traffic-monitoring-tool/">iftop as a good network traffic monitoring tool</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p><strong>iftop</strong> is a command-line tool for real-time network bandwidth monitoring. It displays a continuously updated list of network connections along with the amount of data transferred between them. Connections are shown in a table format and can be sorted by bandwidth usage.</p>



<p>iftop provides various filtering options, allowing you to limit the output to specific hosts, networks, or ports. It supports IPv6 and can display source and destination IP addresses, port numbers, and protocols.</p>



<p>It is particularly useful for monitoring traffic in real time and identifying which services or hosts consume the most bandwidth. It can also help detect network performance issues and assist in troubleshooting.</p>



<p>Overall, iftop is a lightweight yet powerful tool and a valuable addition to any network administrator’s toolkit.</p>



<p>One of the most useful network monitoring tools I use is <strong>iftop</strong>. It becomes especially helpful when the network link is saturated. In practice, it can also help detect abnormal traffic patterns, including DoS attacks. In the example below, I will transfer a large file to a remote machine with a bandwidth limit and observe the traffic using iftop.</p>



<p>First, install iftop on the local machine (in this case, Kali Linux):</p>



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



<figure class="wp-block-image size-full">
<img loading="lazy" decoding="async" width="904" height="422" src="https://soban.pl/wp-content/uploads/2021/11/image-4.png" alt="iftop installation on kali linux" class="wp-image-286" srcset="https://soban.pl/wp-content/uploads/2021/11/image-4.png 904w, https://soban.pl/wp-content/uploads/2021/11/image-4-300x140.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-4-768x359.png 768w" sizes="auto, (max-width: 904px) 100vw, 904px" />
</figure>



<p>The distribution does not matter — iftop is available in most Linux repositories, including Debian.</p>



<p>Now install iftop on the remote machine (Debian Linux):</p>



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



<figure class="wp-block-image size-full">
<img loading="lazy" decoding="async" width="928" height="396" src="https://soban.pl/wp-content/uploads/2021/11/image-6.png" alt="iftop installation on debian linux" class="wp-image-288" srcset="https://soban.pl/wp-content/uploads/2021/11/image-6.png 928w, https://soban.pl/wp-content/uploads/2021/11/image-6-300x128.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-6-768x328.png 768w" sizes="auto, (max-width: 928px) 100vw, 928px" />
</figure>



<p>To start monitoring network traffic, run iftop with the parameters <code>-PpNn</code>:</p>



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



<figure class="wp-block-image size-full">
<img loading="lazy" decoding="async" width="963" height="509" src="https://soban.pl/wp-content/uploads/2021/11/image-9.png" alt="iftop running example" class="wp-image-292" srcset="https://soban.pl/wp-content/uploads/2021/11/image-9.png 963w, https://soban.pl/wp-content/uploads/2021/11/image-9-300x159.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-9-768x406.png 768w" sizes="auto, (max-width: 963px) 100vw, 963px" />
</figure>



<p>Since I am connected to the remote machine via SSH, I can see my active SSH session in the traffic list.</p>



<p>Now let’s go back to the local machine and create a large file:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block">
<pre class="urvanov-syntax-highlighter-plain-tag"># truncate -s 1G 1G-file.txt</pre>
</div>



<p>After creating the 1GB file, let’s transfer it to the remote machine with a bandwidth limit:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block">
<pre class="urvanov-syntax-highlighter-plain-tag"># scp -l 800 -P2222 1G-file.txt soban@soban.pl:~</pre>
</div>



<figure class="wp-block-image size-full">
<img loading="lazy" decoding="async" width="960" height="128" src="https://soban.pl/wp-content/uploads/2021/11/image-10.png" alt="scp transfer with bandwidth limit" class="wp-image-293" srcset="https://soban.pl/wp-content/uploads/2021/11/image-10.png 960w, https://soban.pl/wp-content/uploads/2021/11/image-10-300x40.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-10-768x102.png 768w" sizes="auto, (max-width: 960px) 100vw, 960px" />
</figure>



<p>In this example, the <code>-l 800</code> option limits the transfer rate to 800 Kbit/s. To convert this to KB/s, divide by 8. That gives approximately 100 KB/s (800 / 8 = 100).</p>



<p>To learn more about <code>scp</code> and secure file transfers over SSH, see: <a href="https://soban.pl/securely-copy-files-scp-tool-to-copying-files-by-ssh/" target="_blank" rel="noreferrer noopener"><strong>Securely Copy Files (scp) tool for copying files via SSH</strong></a>.</p>



<p>When sending the file, the traffic on the local machine (outgoing traffic) looks like this:</p>



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



<figure class="wp-block-image size-full">
<img loading="lazy" decoding="async" width="957" height="354" src="https://soban.pl/wp-content/uploads/2021/11/image-11.png" alt="iftop outgoing traffic" class="wp-image-294" srcset="https://soban.pl/wp-content/uploads/2021/11/image-11.png 957w, https://soban.pl/wp-content/uploads/2021/11/image-11-300x111.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-11-768x284.png 768w" sizes="auto, (max-width: 957px) 100vw, 957px" />
</figure>



<p>At the same time, on the remote machine (incoming traffic) it looks like this:</p>



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



<figure class="wp-block-image size-full">
<img loading="lazy" decoding="async" width="964" height="501" src="https://soban.pl/wp-content/uploads/2021/11/image-12.png" alt="iftop incoming traffic" class="wp-image-295" srcset="https://soban.pl/wp-content/uploads/2021/11/image-12.png 964w, https://soban.pl/wp-content/uploads/2021/11/image-12-300x156.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-12-768x399.png 768w" sizes="auto, (max-width: 964px) 100vw, 964px" />
</figure>



<p>As you can see, this approach allows you to observe both outgoing and incoming traffic in real time. Although iftop is simple, it provides powerful visibility into live network activity.</p>



<p>During brute-force attempts, you will usually observe many short-lived connections. In contrast, a DoS attack aims to saturate the bandwidth, which results in high incoming traffic. However, there are situations where traffic spikes are legitimate. In such cases, you may consider limiting connection speed — tools like iptables can help manage that effectively.</p>
<p>Artykuł <a href="https://soban.pl/iftop-as-a-good-network-traffic-monitoring-tool/">iftop as a good network traffic monitoring tool</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Securely Copy Files (scp) tool to copying files by ssh</title>
		<link>https://soban.pl/securely-copy-files-scp-tool-to-copying-files-by-ssh/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Wed, 03 Nov 2021 15:15:57 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Kali]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[ssh]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=264</guid>

					<description><![CDATA[<p>A very good tool for securely copying files via the ssh protocol between machines is scp. It allows you to transfer files to the target machine as well as download from a given source. The tool is usually built into the system so it works on many distributions. Below I will present how you can send and download [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/securely-copy-files-scp-tool-to-copying-files-by-ssh/">Securely Copy Files (scp) tool to copying files by ssh</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>A very good tool for securely copying files via the ssh protocol between machines is <strong>scp</strong>. It allows you to transfer files to the target machine as well as download from a given source. The tool is usually built into the system so it works on many distributions. Below I will present how you can send and download files. For correct file transfer, running ssh service is required, because it is the basis of scp operation. Of course, when using the tool, you can specify the port as the parameter, provided that it has been changed. The standard port used by the ssh daemon is 22. </p>



<p>In Linux, <code>scp</code> (Secure Copy) is a command-line utility used for securely transferring files between local and remote systems. It is a secure alternative to <code>cp</code>, which is not secure when transferring files over a network.</p>



<p>The <code>scp</code> command is commonly used for copying files to or from a remote server. It uses the SSH protocol to securely transfer files and provides the same level of security as SSH. The syntax of the <code>scp</code> command is as follows:</p>



<pre class="wp-block-preformatted">scp [options] [source] [destination]
</pre>



<p>Here, <code>[source]</code> is the file or directory you want to copy, and <code>[destination]</code> is the location where you want to copy the file or directory.</p>



<p>Some common options used with the <code>scp</code> command are:</p>



<ul class="wp-block-list">
<li><code>-r</code>: Copies directories recursively</li>



<li><code>-P</code>: Specifies the port number to use for the SSH connection</li>



<li><code>-i</code>: Specifies the path to the identity file used for authentication</li>
</ul>



<p>For example, to copy a file named <code>file.txt</code> from a remote server to the local machine, you would use the following command:</p>



<pre class="wp-block-preformatted">scp user@remote:/path/to/file.txt /path/to/local/directory/
</pre>



<p>This command will copy the file from the remote server to the local machine at the specified directory.</p>



<p>Similarly, to copy a directory named <code>dir</code> from the local machine to a remote server, you would use the following command:</p>



<pre class="wp-block-preformatted">scp -r /path/to/local/dir user@remote:/path/to/remote/directory/
</pre>



<p>This command will copy the directory and its contents from the local machine to the remote server at the specified directory.</p>



<p id="block-80cf4e6e-5e48-4264-8427-981d64e77dcb">Let&#8217;s start by creating an example file that we will transfer:&nbsp;</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ echo “example text” &gt; example_file</pre></div>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" src="https://soban.pl/wp-content/uploads/2021/11/image.png" alt="" class="wp-image-265" width="397" height="46" srcset="https://soban.pl/wp-content/uploads/2021/11/image.png 591w, https://soban.pl/wp-content/uploads/2021/11/image-300x35.png 300w" sizes="auto, (max-width: 397px) 100vw, 397px" /></figure>



<p id="block-80b0b13d-d72c-489c-862f-a26e6b3a5ddb">in the next step, let&#8217;s move on to uploading the file. In my case, the port from&nbsp;ssh&nbsp;has been changed to 2222:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ scp -P2222 example_file soban@soban.pl:~</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="961" height="200" src="https://soban.pl/wp-content/uploads/2021/11/image-1.png" alt="" class="wp-image-266" srcset="https://soban.pl/wp-content/uploads/2021/11/image-1.png 961w, https://soban.pl/wp-content/uploads/2021/11/image-1-300x62.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-1-768x160.png 768w" sizes="auto, (max-width: 961px) 100vw, 961px" /></figure>



<p id="block-2270aee8-8ab4-44c5-a7d3-09aa7306f03b">The first time you connect, you will be asked for a fingerprint.&nbsp;<br>As you can see, the file has been sent correctly.&nbsp;</p>



<p id="block-69c718e9-c6a5-473f-9890-502c73227342">Instead of the sign at the end of &#8216;<strong>~</strong>&#8216; we can specify where the target file should be placed (<strong>/tmp/example-path</strong>):&nbsp;</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ scp -P2222 example_file soban@soban.pl:/tmp/example-path</pre></div>



<p id="block-faaf0713-3c2f-4f09-811c-733812328d07">There are many combinations, you can send, for example, all files containing the ending (<strong>*.tar.gz</strong>) to the user&#8217;s home directory, which is just symbolized by &#8216;<strong>~</strong>&#8216;:&nbsp;</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ scp -P2222 *.tar.gz soban@soban.pl:~</pre></div>



<p id="block-693e63f4-f081-49a0-8ec3-50ec9bb4274f">An interesting parameter is the &#8216;<strong>-r</strong>&#8216; in&nbsp;scp&nbsp;where we can transfer entire folders, example using copying a folder from local machine to remote machine:&nbsp;</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ scp -P2222 -r /local/directory/ soban@soban.pl:/remote/directory/</pre></div>



<p id="block-5cc2af40-fe4f-41ef-985d-09ccf65dfd3d">OK, after the file has been successfully sent to the target machine, let&#8217;s delete the local file we created above and try to download it back:&nbsp;</p>



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



<p id="block-405a4127-4b66-41aa-932c-0a6ea693375c">Next, let&#8217;s move on to downloading the file from the remote server to the local machine:&nbsp;</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ scp -P2222 soban@soban.pl:example_file ~</pre></div>



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



<p id="block-81b9ceca-5bbc-40b3-99fd-2fb566a53a28">Above I gave an example of how to send an entire folder from a local machine to a remote machine. The other way around, of course, we can also do it. To download a remote folder to a local machine, use the &#8216;<strong>-r</strong>&#8216; parameter:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ scp -P2222 -r soban@soban.pl:/remote/directory/ /local/directory/</pre></div>



<p id="block-de00c7dc-b45d-4764-bf89-b540f489dbea">The&nbsp;scp&nbsp;utility has more parameters, you can get them by reading the man page:&nbsp;</p>



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



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="979" height="632" src="https://soban.pl/wp-content/uploads/2021/11/image-3.png" alt="" class="wp-image-268" srcset="https://soban.pl/wp-content/uploads/2021/11/image-3.png 979w, https://soban.pl/wp-content/uploads/2021/11/image-3-300x194.png 300w, https://soban.pl/wp-content/uploads/2021/11/image-3-768x496.png 768w" sizes="auto, (max-width: 979px) 100vw, 979px" /></figure>



<p id="block-e294f3cd-4591-4784-b847-465ba0398866">It is worth paying attention to the &#8216;<strong>-l</strong>&#8216; parameter where we can set the limit of transferred files. This is useful when transferring larger files so as not to overload your connection.&nbsp;</p>



<p id="block-1f07f453-291e-4f0d-8cba-4097fa301380">If you are tired of constantly entering your password, I encourage you to read how you can connect to&nbsp;ssh&nbsp;without providing a password. Then copying files using&nbsp;<strong>scp</strong>&nbsp;will become more: <a href="https://soban.pl/generate-ssh-key-pair-in-linux/" target="_blank" rel="noreferrer noopener"><strong>generate ssh key pair in linux</strong></a>.</p>



<p>In my opinion, scp is good for transferring files quickly one time. However, as often you exchange files between machines a more convenient way is to use sshfs as described here: <a href="https://soban.pl/sshfs-great-tool-to-mount-remote-file-system/" target="_blank" rel="noreferrer noopener"><strong>sshfs great tool to mount remote file system</strong></a>.</p>
<p>Artykuł <a href="https://soban.pl/securely-copy-files-scp-tool-to-copying-files-by-ssh/">Securely Copy Files (scp) tool to copying files by ssh</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>sshfs great tool to mount remote file system</title>
		<link>https://soban.pl/sshfs-great-tool-to-mount-remote-file-system/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Fri, 22 Oct 2021 13:30:45 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Kali]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[sshfs]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=243</guid>

					<description><![CDATA[<p>SSHFS (SSH File System) is a secure file transfer system that enables users to remotely access and manage files on a remote server over an encrypted SSH (Secure Shell) connection. SSHFS uses the SSH protocol to establish a secure connection between the local and remote systems, which enables users to securely transfer files between the [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/sshfs-great-tool-to-mount-remote-file-system/">sshfs great tool to mount remote file system</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>SSHFS (SSH File System) is a secure file transfer system that enables users to remotely access and manage files on a remote server over an encrypted SSH (Secure Shell) connection. SSHFS uses the SSH protocol to establish a secure connection between the local and remote systems, which enables users to securely transfer files between the two systems.</p>



<p>To use SSHFS, the user needs to have SSHFS installed on their local system as well as the remote system that they want to connect to. Once SSHFS is installed, the user can mount the remote system as a local directory on their system, and access the remote files as if they were stored locally.</p>



<p>SSHFS provides a secure and convenient way to access and manage files on remote systems, without the need for additional software or complicated configuration. It also enables users to access files on remote systems using standard file operations, such as copying, moving, and deleting, making it a simple and effective way to manage files on remote systems.</p>



<p><strong><strong>SSH Filesystem</strong></strong> (<strong>sshfs</strong>) is a very useful tool for remotely transferring files over the ssh protocol. An additional advantage of the whole is encryption. This is a convenient way to mount a remote folder to delete files. Below I will try to briefly introduce how to install sshfs and how to mount the folder remotely. Additionally, we will make an entry in <strong>/etc/fstab</strong> at the end, so that the resource itself is mounted after restarting the system. Let&#8217;s move on to installing the tool itself: </p>



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



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="432" src="https://soban.pl/wp-content/uploads/2021/10/image-82-1024x432.png" alt="" class="wp-image-244" srcset="https://soban.pl/wp-content/uploads/2021/10/image-82-1024x432.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-82-300x127.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-82-768x324.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-82.png 1128w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>In this case, as you can see, the installation was done on kali linuxe, however the procedure is the same on debian.</p>



<p>Let&#8217;s move on to the file mounting itself, at this point I will point out that the default port is 22. In my case, however, the port has been changed to 2222. For services such as ssh, I try to change the default ports so as not to get caught by bots and not end up in the database such as <a href="https://www.shodan.io/" target="_blank" rel="noreferrer noopener">shodan.io</a>. The command itself in this case is very simple, but first we need to create a folder: </p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ mkdir /home/kali/myremotedir</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="402" height="65" src="https://soban.pl/wp-content/uploads/2021/10/image-83.png" alt="" class="wp-image-245" srcset="https://soban.pl/wp-content/uploads/2021/10/image-83.png 402w, https://soban.pl/wp-content/uploads/2021/10/image-83-300x49.png 300w" sizes="auto, (max-width: 402px) 100vw, 402px" /></figure>



<p>Let&#8217;s try to mount a remote folder:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ sshfs soban@soban.pl:/home/soban/ /home/kali/myremotedir -p 2222</pre></div>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="148" src="https://soban.pl/wp-content/uploads/2021/10/image-84-1024x148.png" alt="" class="wp-image-246" srcset="https://soban.pl/wp-content/uploads/2021/10/image-84-1024x148.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-84-300x43.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-84-768x111.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-84.png 1089w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>During mounting, we will be asked if the fingerprint is correct. Then for the system password. The command itself can be disassembled into &#8216;<strong>soban</strong>&#8216; &#8211; this is the username. Then &#8216;<strong>soban.pl</strong>&#8216; is the domain name, you can also put the IP address here. The next &#8216;<strong>/home/soban</strong>&#8216; element is the folder that will be mounted. And after the space &#8216;<strong>/home/kali/myremotedir</strong>&#8216; we give the folder where the remote folder should be mounted. If everything went as planned, we can list &#8216;<strong>/home/kali/myremotedir</strong>&#8216; and it should list the contents of the remotely mounted folder &#8216;<strong>/home/soban</strong>&#8216;. Let&#8217;s list the contents of the &#8216;<strong>/home/kali/myremotedir</strong>&#8216; folder:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ ls -ltr /home/kali/myremotedir</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="642" height="159" src="https://soban.pl/wp-content/uploads/2021/10/image-85.png" alt="" class="wp-image-247" srcset="https://soban.pl/wp-content/uploads/2021/10/image-85.png 642w, https://soban.pl/wp-content/uploads/2021/10/image-85-300x74.png 300w" sizes="auto, (max-width: 642px) 100vw, 642px" /></figure>



<p>Let&#8217;s create a remote file:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ echo 'some text' &gt; /home/kali/myremotedir/example
$ ls -ltr /home/kali/myremotedir</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="664" height="259" src="https://soban.pl/wp-content/uploads/2021/10/image-86.png" alt="" class="wp-image-248" srcset="https://soban.pl/wp-content/uploads/2021/10/image-86.png 664w, https://soban.pl/wp-content/uploads/2021/10/image-86-300x117.png 300w" sizes="auto, (max-width: 664px) 100vw, 664px" /></figure>



<p>Now let&#8217;s unmount the remote folder and try listing it again:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ umount /home/kali/myremotedir
$ ls -ltr /home/kali/myremotedir</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="445" height="155" src="https://soban.pl/wp-content/uploads/2021/10/image-87.png" alt="" class="wp-image-249" srcset="https://soban.pl/wp-content/uploads/2021/10/image-87.png 445w, https://soban.pl/wp-content/uploads/2021/10/image-87-300x104.png 300w" sizes="auto, (max-width: 445px) 100vw, 445px" /></figure>



<p>As expected, the folder is empty and the file we created was created on a remotely mounted drive. After unmounting as you can see the file &#8216;<strong>/home/kali/myremotedir/example</strong>&#8216;.</p>



<p>The next step is to create a private key to mount the folder without entering a password. It is very important not to send nikmou your private key. How we can generate and add a public key to a remote server can be read here: &#8220;<a href="https://soban.pl/generate-ssh-key-pair-in-linux/" target="_blank" rel="noreferrer noopener">Generate SSH key pair in Linux</a>&#8220;.</p>



<p>Now we will try to add an entry to <strong>/etc/fstab</strong> which will allow automatic mounting on startup of the remote folder system.<br>To do this, edit the <strong>/etc/fstab</strong> entry and add this entry:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">#edit this entry and put correct data
sshfs#soban@soban.pl:/home/soban /home/kali/myremotedir fuse auto,user,_netdev,reconnect,identityfile=/home/kali/.ssh/id_rsa,port=2222,uid=1000,gid=1000,allow_other 0 0</pre></div>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="245" src="https://soban.pl/wp-content/uploads/2021/10/image-92-1024x245.png" alt="" class="wp-image-259" srcset="https://soban.pl/wp-content/uploads/2021/10/image-92-1024x245.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-92-300x72.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-92-768x184.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-92-1536x367.png 1536w, https://soban.pl/wp-content/uploads/2021/10/image-92.png 1698w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>It is important that all data is correct, in order to verify the parameters, you can use the command for this &#8216;<strong>id</strong>&#8216;:</p>



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



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="100" src="https://soban.pl/wp-content/uploads/2021/10/image-94-1024x100.png" alt="" class="wp-image-261" srcset="https://soban.pl/wp-content/uploads/2021/10/image-94-1024x100.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-94-300x29.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-94-768x75.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-94.png 1067w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Now we can move on to mounting the resource:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># mount /home/kali/myremotedir</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="895" height="118" src="https://soban.pl/wp-content/uploads/2021/10/image-93.png" alt="" class="wp-image-260" srcset="https://soban.pl/wp-content/uploads/2021/10/image-93.png 895w, https://soban.pl/wp-content/uploads/2021/10/image-93-300x40.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-93-768x101.png 768w" sizes="auto, (max-width: 895px) 100vw, 895px" /></figure>



<p>When mounting for the first time, we may be asked to accept and confirm that the fingerprint is correct. After verifying the correctness of mounting the remote resource, we can restart the system. One note here, the system may get up longer.</p>
<p>Artykuł <a href="https://soban.pl/sshfs-great-tool-to-mount-remote-file-system/">sshfs great tool to mount remote file system</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Generate SSH key pair in Linux</title>
		<link>https://soban.pl/generate-ssh-key-pair-in-linux/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Fri, 22 Oct 2021 12:32:08 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Kali]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[ssh]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=251</guid>

					<description><![CDATA[<p>A very convenient way to log into remote systems via ssh is without the use of passwords. Here it is very important not to share your private key with anyone. Currently, when trying to connect, I am asked for the password to the server: During the connection, we will be asked if the fingerprint is [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/generate-ssh-key-pair-in-linux/">Generate SSH key pair in Linux</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>A very convenient way to log into remote systems via ssh is without the use of passwords. Here it is very important not to share your private key with anyone. Currently, when trying to connect, I am asked for the password to the server:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ ssh soban@soban.pl -p2222</pre></div>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="374" src="https://soban.pl/wp-content/uploads/2021/10/image-90-1024x374.png" alt="" class="wp-image-254" srcset="https://soban.pl/wp-content/uploads/2021/10/image-90-1024x374.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-90-300x109.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-90-768x280.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-90.png 1261w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>During the connection, we will be asked if the fingerprint is correct. Then enter the user password that is set on the remote server. During the ssh command &#8216;<strong>soban@soban.pl -p2222</strong>&#8216; I gave the username &#8216;<strong>soban</strong>&#8216; then the domain &#8216;<strong>soban.pl</strong>&#8216; and &#8216;<strong>-p2222</strong>&#8216; port <strong>&#8216;2222&#8217;</strong>. The default port after ssh is <strong>22</strong>, but in this case I changed it so that it does not come out on scans &#8211; this increases security as often bots / hackers look for port <strong>22</strong>, which is the default ssh port set. </p>



<p>Let&#8217;s move on to generating the key and copying it to the server:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ ssh-keygen -t rsa</pre></div>



<p>This is how the key generation looks like, I hit enter for each question:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="753" height="539" src="https://soban.pl/wp-content/uploads/2021/10/image-88.png" alt="" class="wp-image-252" srcset="https://soban.pl/wp-content/uploads/2021/10/image-88.png 753w, https://soban.pl/wp-content/uploads/2021/10/image-88-300x215.png 300w" sizes="auto, (max-width: 753px) 100vw, 753px" /></figure>



<p>As a result, a private key was generated: (<strong>/home/kali/.ssh/id_rsa</strong>) and a public key (<strong>/home/kali/.ssh/id_rsa</strong>)  that we will place on the remote server:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ ssh soban@soban.pl -p2222 "echo \"`cat ~/.ssh/id_rsa.pub`\" &gt;&gt; .ssh/authorized_keys"</pre></div>



<p>The last time we log in to the server by entering the password. When logging in, we will not be asked for a password now. This way we are able to add our public key (.ssh / authorized_keys) to the remote server. </p>



<p></p>
<p>Artykuł <a href="https://soban.pl/generate-ssh-key-pair-in-linux/">Generate SSH key pair in Linux</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>More security wp-admin in nginx</title>
		<link>https://soban.pl/more-security-wp-admin-in-nginx/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Thu, 21 Oct 2021 16:44:39 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Wordpress]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=229</guid>

					<description><![CDATA[<p>Some time ago I noticed that my wordpress hacks are being hacked by logging into the backend of the website. A bot or a hacker is trying to do this using a set of passwords. I decided to secure the website&#8217;s backend by requiring additional authentication. In nginxe we can set this up by: We [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/more-security-wp-admin-in-nginx/">More security wp-admin in nginx</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Some time ago I noticed that my wordpress hacks are being hacked by logging into the backend of the website. A bot or a hacker is trying to do this using a set of passwords. I decided to secure the website&#8217;s backend by requiring additional authentication. In nginxe we can set this up by:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">location ~ ^/(wp-admin|wp-login\.php) {
           auth_basic "Restricted";
           auth_basic_user_file /etc/nginx/.htpasswd;
           proxy_pass http://upstream-webservers;
           proxy_redirect https://upstream-webservers http://upstream-webservers;
           expires off;
           proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
           proxy_set_header        Host            $host;
           proxy_set_header        X-Real-IP       $remote_addr;
           proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      }</pre></div>



<p>We still need to provide the username for authorization and save to the file (/etc/nginx/.htpasswd) as we entered in the nginx configuration file. In &#8220;my_user_name&#8221;, replace the login of the user with which we will be authorized.:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># echo -n 'my_user_name:' &gt;&gt; /etc/nginx/.htpasswd</pre></div>



<p> And the encrypted password has been set by openssl:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># openssl passwd -apr1 &gt;&gt; /etc/nginx/.htpasswd</pre></div>



<p>Openssl will ask you to come up with a password and enter it twice:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="809" height="71" src="https://soban.pl/wp-content/uploads/2021/10/image-76.png" alt="" class="wp-image-232" srcset="https://soban.pl/wp-content/uploads/2021/10/image-76.png 809w, https://soban.pl/wp-content/uploads/2021/10/image-76-300x26.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-76-768x67.png 768w" sizes="auto, (max-width: 809px) 100vw, 809px" /></figure>



<p>As a result, we will get a file with an encrypted password:</p>



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



<p>Before reloading nginx, we do a configuration verification:</p>



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



<p>If everything is set correctly, we should receive the following message:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="811" height="83" src="https://soban.pl/wp-content/uploads/2021/10/image-81.png" alt="" class="wp-image-240" srcset="https://soban.pl/wp-content/uploads/2021/10/image-81.png 811w, https://soban.pl/wp-content/uploads/2021/10/image-81-300x31.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-81-768x79.png 768w" sizes="auto, (max-width: 811px) 100vw, 811px" /></figure>



<p>Now we can restart the service nginx:</p>



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



<p>The final verification will be to log in to the backend (e.g. www.example-page-wordpress.pl/<strong>wp-admin</strong>/), as a result, we should be asked for the login and password that we created above:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="738" height="458" src="https://soban.pl/wp-content/uploads/2021/10/image-79.png" alt="" class="wp-image-235" srcset="https://soban.pl/wp-content/uploads/2021/10/image-79.png 738w, https://soban.pl/wp-content/uploads/2021/10/image-79-300x186.png 300w" sizes="auto, (max-width: 738px) 100vw, 738px" /></figure>



<p>This is a simple trick to protect your wordpress from bot attacks. However, it should be remembered that we do not share passwords with anyone and setting default usernames and simple passwords is asking for a problem.</p>
<p>Artykuł <a href="https://soban.pl/more-security-wp-admin-in-nginx/">More security wp-admin in nginx</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Useful tricks to view and search logs</title>
		<link>https://soban.pl/useful-tricks-to-view-and-search-logs/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Thu, 21 Oct 2021 13:12:36 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nginx]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=216</guid>

					<description><![CDATA[<p>It often happens that we have to catch a given message, e.g. &#8220;error&#8221; while browsing the logs. Alternatively, we look for the occurrence of a given phrase in the old files. Both &#8220;tail&#8221; and &#8220;grep&#8221; are very useful for this. Especially if the logs are set in verbal mode, where there is a lot of [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/useful-tricks-to-view-and-search-logs/">Useful tricks to view and search logs</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>It often happens that we have to catch a given message, e.g. &#8220;<strong>error</strong>&#8221; while browsing the logs. Alternatively, we look for the occurrence of a given phrase in the old files. Both &#8220;<strong>tail</strong>&#8221; and &#8220;<strong>grep</strong>&#8221; are very useful for this. Especially if the logs are set in verbal mode, where there is a lot of messages in the log. We can also exclude certain phrases after parsing the information set. It is enough to use grep properly.</p>



<p>Let&#8217;s start by looking at all nginx logs.</p>



<p>In this case, sorting from oldest to newest is very useful as we know where to find the newest log entries:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># cd /var/log/nginx/
# ls -ltr *</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="832" height="622" src="https://soban.pl/wp-content/uploads/2021/10/image-75.png" alt="" class="wp-image-224" srcset="https://soban.pl/wp-content/uploads/2021/10/image-75.png 832w, https://soban.pl/wp-content/uploads/2021/10/image-75-300x224.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-75-768x574.png 768w" sizes="auto, (max-width: 832px) 100vw, 832px" /></figure>



<p>If we are interested in the latest data, we will focus on the access-soban.pl.log file.</p>



<p>I know that my website is monitored by <a href="https://uptimerobot.com/" target="_blank" rel="noreferrer noopener">uptimerobot.com</a> and I would like to find out, for example, from what IP address the website gets a query, e.g. to add it to the firewall as trusted:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># grep -i uptime access-soban.pl.log</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="994" height="395" src="https://soban.pl/wp-content/uploads/2021/10/image-71.png" alt="" class="wp-image-219" srcset="https://soban.pl/wp-content/uploads/2021/10/image-71.png 994w, https://soban.pl/wp-content/uploads/2021/10/image-71-300x119.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-71-768x305.png 768w" sizes="auto, (max-width: 994px) 100vw, 994px" /></figure>



<p>As you can see, in this case, the bot that is querying the server has the IP address: <strong>208.115.191.21</strong>. If I wanted to see all calls from this IP address, I could view them this way:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># grep 208.115.199.21 access-soban.pl.log* | less</pre></div>



<p>If I press (<strong>shift + g</strong>) I&#8217;ll go to the bottom of the log:</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="668" src="https://soban.pl/wp-content/uploads/2021/10/image-72-1024x668.png" alt="" class="wp-image-220" srcset="https://soban.pl/wp-content/uploads/2021/10/image-72-1024x668.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-72-300x196.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-72-768x501.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-72.png 1132w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>It is worth noting that in this case the file in which the query is located is also given.</p>



<p>Now suppose I would like the logs, but without the &#8220;<strong>uptimerobot</strong>&#8220;:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># grep -v uptimerobot access-soban.pl.log* | less</pre></div>



<p>This way all queries containing the word &#8220;uptimerobots&#8221; were cut. We can of course diminish the output from the console more by adding &#8220;<strong>| grep -v</strong>&#8221; possibly. Let&#8217;s cut out &#8220;<strong>sitemap</strong>&#8220;:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># grep -v uptimerobot access-soban.pl.log* | grep -v sitemap | less</pre></div>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="693" src="https://soban.pl/wp-content/uploads/2021/10/image-73-1024x693.png" alt="" class="wp-image-221" srcset="https://soban.pl/wp-content/uploads/2021/10/image-73-1024x693.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-73-300x203.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-73-768x520.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-73.png 1117w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>One handy thing is to direct the stream from the console output to a file. We do this as follows &#8220;<strong>/tmp/file.log</strong>&#8220;:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># grep -v uptimerobot access-soban.pl.log | grep -v sitemap &gt;&gt; /tmp/file.log</pre></div>



<p>Additionally, we can pack the file:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># tar -zcf /tmp/file.log.tar.gz /tmp/file.log</pre></div>



<p>After packing the file, we can send it to another person. Sensitive data, such as inquiries or logins, can be cut using grep, as we did above.</p>



<p>Now let&#8217;s move on to one of the most useful tools for watching live what happens when someone enters a page:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># tail -f *.log</pre></div>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="217" src="https://soban.pl/wp-content/uploads/2021/10/image-74-1024x217.png" alt="" class="wp-image-222" srcset="https://soban.pl/wp-content/uploads/2021/10/image-74-1024x217.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-74-300x64.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-74-768x163.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-74.png 1130w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>At this point it is worth noting that we &#8220;caught&#8221; the logs from the files: &#8220;access-soban.pl.log&#8221; and &#8220;error-soban.pl.log&#8221;. However, the &#8220;error-soban.pl.log&#8221; log is empty, so its content is not shown below. However, if something came up, we would see the contents of the updated file on the console.</p>



<p>Useful at this point is to combine grep and tail. We&#8217;re assuming we don&#8217;t want uptimerobots to bump into our consoles while observing the logs, so we&#8217;re going to cut them like this:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># tail -f *.log | grep -v uptimerobots</pre></div>



<p>The given examples can be modified in any way. I encourage you to use it in various combinations of tail and grep, especially in situations where erros/warning are repeated. Of course, not only in nginx logs you can use these commands. In all logs where we operate on text, be it system or application. Passing the text mentioned above is very helpful.</p>
<p>Artykuł <a href="https://soban.pl/useful-tricks-to-view-and-search-logs/">Useful tricks to view and search logs</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Check network connection and open TCP port via netcat</title>
		<link>https://soban.pl/check-network-connection-and-open-tcp-port-via-netcat/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Thu, 21 Oct 2021 10:40:49 +0000</pubDate>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[Security]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=197</guid>

					<description><![CDATA[<p>Netcat, also known as &#8220;nc,&#8221; is a versatile networking tool that is commonly used in Linux and other Unix-like operating systems. It is a command-line utility that can be used for various network-related tasks, such as port scanning, file transfer, and even as a lightweight web server. The primary function of Netcat is to create [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/check-network-connection-and-open-tcp-port-via-netcat/">Check network connection and open TCP port via netcat</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Netcat, also known as &#8220;nc,&#8221; is a versatile networking tool that is commonly used in Linux and other Unix-like operating systems. It is a command-line utility that can be used for various network-related tasks, such as port scanning, file transfer, and even as a lightweight web server.</p>



<p>The primary function of Netcat is to create network connections between two hosts, allowing data to be transferred between them. It can establish a connection as a client or a server, and it supports both TCP and UDP protocols. This makes it useful for testing network services, troubleshooting network issues, and performing security assessments.</p>



<p>Netcat can be used to scan for open ports on a remote host, allowing system administrators to identify potential security vulnerabilities. It can also be used to transfer files between hosts, similar to the way that the &#8220;cp&#8221; command works in Linux. Additionally, it can be used to create a simple web server, allowing files to be served over HTTP.</p>



<p>One of the key features of Netcat is its ability to operate in both interactive and non-interactive modes. In interactive mode, it acts like a chat program, allowing users to communicate with each other in real-time. In non-interactive mode, it can be used as a background process that quietly sends or receives data without any user interaction.</p>



<p>Overall, Netcat is a powerful and flexible tool that can be used for a wide range of networking tasks. Its simplicity and ease of use make it a popular choice among system administrators, network engineers, and security professionals.</p>



<p>Sometimes network connections are blocked by various network devices. In the verification of the connection over TCP, we can use, for example, telnet. After all, before we start a server-side service like jboss, we can use a simple utility like netcat to open the port.</p>



<p>In this example we will be using two machines. However, one of them is &#8220;<strong>host-soban-pl</strong>&#8221; with the IP address: <strong>10.10.14.100</strong>:</p>



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



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="241" src="https://soban.pl/wp-content/uploads/2021/10/image-66-1024x241.png" alt="" class="wp-image-208" srcset="https://soban.pl/wp-content/uploads/2021/10/image-66-1024x241.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-66-300x71.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-66-768x181.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-66.png 1249w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p> The second is &#8220;<strong>soban-pl</strong>&#8221; with the IP address: <strong>10.10.11.105</strong>:</p>



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



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="235" src="https://soban.pl/wp-content/uploads/2021/10/image-67-1024x235.png" alt="" class="wp-image-209" srcset="https://soban.pl/wp-content/uploads/2021/10/image-67-1024x235.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-67-300x69.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-67-768x176.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-67.png 1246w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Below, for example, I will show you how to check an already open tcp connection and one that is closed. On the other side, on port 80, I have an open port with nginx:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ telnet 10.10.11.105 80</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="558" height="157" src="https://soban.pl/wp-content/uploads/2021/10/image-56.png" alt="" class="wp-image-198" srcset="https://soban.pl/wp-content/uploads/2021/10/image-56.png 558w, https://soban.pl/wp-content/uploads/2021/10/image-56-300x84.png 300w" sizes="auto, (max-width: 558px) 100vw, 558px" /></figure>



<p>Nmap below confirms port opening, additionally identified the service as http:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ nmap 10.10.11.105 -p 80</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="787" height="204" src="https://soban.pl/wp-content/uploads/2021/10/image-57.png" alt="" class="wp-image-199" srcset="https://soban.pl/wp-content/uploads/2021/10/image-57.png 787w, https://soban.pl/wp-content/uploads/2021/10/image-57-300x78.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-57-768x199.png 768w" sizes="auto, (max-width: 787px) 100vw, 787px" /></figure>



<p>The conclusion is that the service has network transitions and you can correctly connect over TCP. Now it will try to open a connection that does not exist, e.g. on port 81.</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ telnet 10.10.11.105 81</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="744" height="72" src="https://soban.pl/wp-content/uploads/2021/10/image-58.png" alt="" class="wp-image-200" srcset="https://soban.pl/wp-content/uploads/2021/10/image-58.png 744w, https://soban.pl/wp-content/uploads/2021/10/image-58-300x29.png 300w" sizes="auto, (max-width: 744px) 100vw, 744px" /></figure>



<p>As you can see, the connection is not possible because the port is closed. The assumption is that the port may be open, but for example the firewall blocks it. Then you need to set the appropriate rules on it.</p>



<p>After all, in this case I know that the firewall does not block anything, so it will try to open the port with netcat. First we need to install netcat in debian, it is done like this:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># apt install netcat-traditional</pre></div>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="350" src="https://soban.pl/wp-content/uploads/2021/10/image-59-1024x350.png" alt="" class="wp-image-201" srcset="https://soban.pl/wp-content/uploads/2021/10/image-59-1024x350.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-59-300x103.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-59-768x263.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-59.png 1175w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Now let&#8217;s move on to running netcat on port 81:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># netcat -l -p 81 &amp;</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="427" height="45" src="https://soban.pl/wp-content/uploads/2021/10/image-60.png" alt="" class="wp-image-202" srcset="https://soban.pl/wp-content/uploads/2021/10/image-60.png 427w, https://soban.pl/wp-content/uploads/2021/10/image-60-300x32.png 300w" sizes="auto, (max-width: 427px) 100vw, 427px" /></figure>



<p>In this case, I specially gave the command &#8216;&amp;&#8217; at the end to leave the netcat process in the background. At this point, netcat is listening on port 81.</p>



<p>Now we can proceed to checking the correctness of the connection with the use of telnet:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">$ telnet 10.10.11.105 81</pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="648" height="90" src="https://soban.pl/wp-content/uploads/2021/10/image-61.png" alt="" class="wp-image-203" srcset="https://soban.pl/wp-content/uploads/2021/10/image-61.png 648w, https://soban.pl/wp-content/uploads/2021/10/image-61-300x42.png 300w" sizes="auto, (max-width: 648px) 100vw, 648px" /></figure>



<p>In the meantime, on the server machine, we can use the netstat tool to verify the connection and check from which machine the traffic is coming:</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="92" src="https://soban.pl/wp-content/uploads/2021/10/image-68-1024x92.png" alt="" class="wp-image-210" srcset="https://soban.pl/wp-content/uploads/2021/10/image-68-1024x92.png 1024w, https://soban.pl/wp-content/uploads/2021/10/image-68-300x27.png 300w, https://soban.pl/wp-content/uploads/2021/10/image-68-768x69.png 768w, https://soban.pl/wp-content/uploads/2021/10/image-68.png 1026w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>As you can see, a correct connection from the 10.10.14.100 host has been established with the server on 10.10.11.105 on port 81.</p>



<p>To end the call, hit &#8216;<strong>^]</strong>&#8216; (<strong>ctrl +]</strong>), then type quit and enter.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="560" height="157" src="https://soban.pl/wp-content/uploads/2021/10/image-65.png" alt="" class="wp-image-207" srcset="https://soban.pl/wp-content/uploads/2021/10/image-65.png 560w, https://soban.pl/wp-content/uploads/2021/10/image-65-300x84.png 300w" sizes="auto, (max-width: 560px) 100vw, 560px" /></figure>



<p>In this way, we can verify the correctness of the network connection and whether any firewall or other network problem is an obstacle to its correct establishment. Netcat is a very powerful and useful tool, you can use it to transfer files etc. Netstat is also very useful in situations where network congestion occurs and one of the hosts is attacked. It is then easy to notice that a large number of network connections are made.</p>
<p>Artykuł <a href="https://soban.pl/check-network-connection-and-open-tcp-port-via-netcat/">Check network connection and open TCP port via netcat</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
