<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Viktor Hadzhiyski</title>
    <description>The latest articles on DEV Community by Viktor Hadzhiyski (@viktor_hadzhiyski_2a90f12).</description>
    <link>https://dev.to/viktor_hadzhiyski_2a90f12</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1587109%2Fac00aea4-87eb-484a-8a8f-6b1c68c28e3f.jpg</url>
      <title>DEV Community: Viktor Hadzhiyski</title>
      <link>https://dev.to/viktor_hadzhiyski_2a90f12</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/viktor_hadzhiyski_2a90f12"/>
    <language>en</language>
    <item>
      <title>Port change Ubuntu 24.04 LTS noble</title>
      <dc:creator>Viktor Hadzhiyski</dc:creator>
      <pubDate>Tue, 20 Aug 2024 09:49:10 +0000</pubDate>
      <link>https://dev.to/viktor_hadzhiyski_2a90f12/port-change-ubuntu-2404-lts-noble-36he</link>
      <guid>https://dev.to/viktor_hadzhiyski_2a90f12/port-change-ubuntu-2404-lts-noble-36he</guid>
      <description>&lt;h2&gt;
  
  
  I want to answer this in case someone else is going through the same madness I was yesterday morning. Found very little information on the internet so I want to share this with you here.
&lt;/h2&gt;




&lt;p&gt;Before getting into the guide I want to thank &lt;a href="https://serverfault.com/questions/1159599/how-to-change-the-ssh-server-port-on-ubuntu" rel="noopener noreferrer"&gt;Phanaz&lt;/a&gt; whose answer on serverfault helped crack the answer to this riddle. &lt;/p&gt;

&lt;p&gt;If Google or GPT haven't helped,  I hope this does! &lt;/p&gt;




&lt;p&gt;I assume that you already tried to change your port in &lt;code&gt;ssh_cofnig&lt;/code&gt;, &lt;code&gt;sshd_config&lt;/code&gt; and it hasn't worked. That's because Ubuntu 24.04 want's things done differently and I'm not going to pretend I know why. &lt;/p&gt;

&lt;p&gt;Comment out the port section for starters if you have them uncommented.&lt;/p&gt;

&lt;p&gt;Instead go to &lt;br&gt;
&lt;code&gt;/etc/systemd/system/sockets.target.wants&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In there you should have the &lt;code&gt;ssh.socket&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Edit &lt;code&gt;ssh.socket&lt;/code&gt; with sudo nano or whatever your favourite editor. You should see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Unit]
Description=OpenBSD Secure Shell server socket
Before=sockets.target ssh.service
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run

[Socket]
ListenStream=2469
Accept=no 
FreeBind=yes 

[Install]
WantedBy=sockets.target
RequiredBy=ssh.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change this to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Unit]
Description=OpenBSD Secure Shell server socket
Before=sockets.target ssh.service
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run

[Socket]
ListenStream=
ListenStream=2469
Accept=no 
FreeBind=yes 

[Install]
WantedBy=sockets.target
RequiredBy=ssh.service
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now save the file and update the daemon by running &lt;code&gt;systemctl daemon-reload&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Then &lt;code&gt;systemctl restart ssh.socket&lt;/code&gt; to finalise everything.&lt;/p&gt;

&lt;p&gt;Try in the reverse order e.g. &lt;code&gt;systemctl restart ssh.socket&lt;/code&gt; then &lt;code&gt;systemctl daemon-reload&lt;/code&gt; if you get any errors. It was very early morning and my notes are unclear.&lt;/p&gt;

&lt;p&gt;Finally check with &lt;code&gt;systemctl status ssh.socket&lt;/code&gt; - if it shows running and enabled, the rest of your ssh configuration is also fine, this should work. &lt;/p&gt;




&lt;p&gt;This worked for me and I hope it does for you too. First time I write in a forum. Always thought it was for crazies and maybe I am a crazy after this debacle. But I don't want anyone else going through this, Cursing Google, GPT and their life at 4 in the morning. &lt;/p&gt;

&lt;p&gt;Cheers 🍻&lt;/p&gt;

</description>
      <category>linux</category>
      <category>ubuntu</category>
      <category>ports</category>
      <category>change</category>
    </item>
  </channel>
</rss>
