<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Network on TokkNet</title><link>https://tokknet.eu/en/tags/network/</link><description>Recent content in Network on TokkNet</description><generator>Hugo</generator><language>en-US</language><managingEditor>blog@tokknet.eu (Tokk)</managingEditor><webMaster>blog@tokknet.eu (Tokk)</webMaster><lastBuildDate>Thu, 10 Apr 2025 10:59:49 +0200</lastBuildDate><atom:link href="https://tokknet.eu/en/tags/network/index.xml" rel="self" type="application/rss+xml"/><item><title>Determine route for IP</title><link>https://tokknet.eu/en/2025/determine-route-for-ip/</link><pubDate>Thu, 10 Apr 2025 10:59:49 +0200</pubDate><author>blog@tokknet.eu (Tokk)</author><guid>https://tokknet.eu/en/2025/determine-route-for-ip/</guid><description>&lt;p>To determine the route for a specific IP on a system with several gateways, &lt;code>ip route show to match&lt;/code> can be used:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>user@system:~$ ip route show to match 10.190.10.6
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>default via 192.168.2.1 dev ens160 proto static
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>10.0.0.0/8 via 192.168.2.250 dev ens160 proto static src 192.168.2.10
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div></description></item><item><title>Deactivate password login via SSH under Ubuntu</title><link>https://tokknet.eu/en/2024/deactivate-password-login-via-ssh-under-ubuntu/</link><pubDate>Fri, 28 Jun 2024 09:40:27 +0200</pubDate><author>blog@tokknet.eu (Tokk)</author><guid>https://tokknet.eu/en/2024/deactivate-password-login-via-ssh-under-ubuntu/</guid><description>&lt;p>One of the first things I always change on a new server is the &lt;code>sshd_config&lt;/code>, deactivating the login via SSH with password.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>PubkeyAuthentication yes
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ChallengeResponseAuthentication no
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>PasswordAuthentication no
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>PermitEmptyPasswords no
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>KbdInteractiveAuthentication no
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>UsePAM no
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Normally you assume that the entries are correct and working, test the login from your own PC and are satisfied that the certificate is being used.&lt;/p>
&lt;h3 id="cloud-init">Cloud Init&lt;/h3>
&lt;p>Of course, Ubuntu is nowadays delivered with Cloud Init and since Ubuntu 20.04 this comes with a new config file called &lt;code>/etc/ssh/sshd_config.d/50-cloud-init.conf&lt;/code>, which contains one single line:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-nginx" data-lang="nginx">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">PasswordAuthentication&lt;/span> &lt;span style="color:#e6db74">yes&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Since the inclusion of the &lt;code>sshd_config.d&lt;/code> directory takes place very high up in the &lt;code>sshd_config&lt;/code>, this is almost always the first occurrence of the &lt;code>PasswordAuthentication&lt;/code> directive and is therefore retained and the password login remains activated despite all other settings.&lt;br>
To completely deactivate the option of logging in with a password, the file must therefore be deleted or edited. However, as this file only fulfills one purpose, it can be deleted with a clear conscience.&lt;/p>
&lt;h3 id="concluding-remarks">Concluding remarks&lt;/h3>
&lt;ol>
&lt;li>This situation clearly shows that security settings must always be tested, no matter how carefully the configuration is carried out, even from the perspective of an external context, in this case forcing the login without your own certificate.&lt;/li>
&lt;li>WTF Canonical?&lt;/li>
&lt;/ol></description></item><item><title>Unprivileged Binding to Privileged Ports</title><link>https://tokknet.eu/en/2024/unprivileged-binding-to-privileged-ports/</link><pubDate>Thu, 27 Jun 2024 09:43:27 +0200</pubDate><author>blog@tokknet.eu (Tokk)</author><guid>https://tokknet.eu/en/2024/unprivileged-binding-to-privileged-ports/</guid><description>&lt;p>Normally, the Linux kernel does not allow unprivileged processes to bind to ports below 1024. Therefore, most (web) server processes run as root. From a security point of view, it is of course not ideal for the processes that handle requests from the Internet to have extensive rights, as this naturally leads directly to root rights on the entire system in the event of a hostile takeover of the process.&lt;br>
At this point, however, Systemd offers the possibility of allowing our service to bind to the ports by granting the corresponding process the authorization to bind to the ports below 1024 via &lt;code>AmbientCapabilities =CAP_NET_BIND_SERVICE&lt;/code>. An overview of all other authorizations that can be granted can be found, for example, in the &lt;a href="https://man7.org/linux/man-pages/man7/capabilities.7.html">Linux man page on capabilities&lt;/a>.&lt;/p>
&lt;p>On this occasion, you can use &lt;code>CapabilityBoundingSet=CAP_NET_BIND_SERVICE &lt;/code> to restrict that the service may only receive this authorization and cannot receive any other &lt;strong>authorizations&lt;/strong>.
The unit file should then look like this:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-systemd" data-lang="systemd">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#66d9ef">[Service]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#a6e22e">CapabilityBoundingSet&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">CAP_NET_BIND_SERVICE&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#a6e22e">AmbientCapabilities&lt;/span>&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#e6db74">CAP_NET_BIND_SERVICE&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>It is best to create such changes as a drop-in in a separate &lt;a href="https://tokknet.eu/en/2024/systemd-overrides-customization-of-system-services/">override file&lt;/a>.&lt;/p>
&lt;p>Translated with DeepL.com (free version)&lt;/p></description></item></channel></rss>