Ubuntu CT very twisted SSH situation

sysbitnet

Renowned Member
Apr 20, 2016
21
1
68
Switzerland
sysbitnet.com
Greetings good people :),

We just get a very twisted situation with Ubuntu container machines.

In CT version Ubuntu 20.04.5 LTS

If we customize ssh port in config file # nano etc/ssh/sshd_config and set the custom Port 2222 save file.
Restart the ssh service with # service ssh restart and after that check the service ssh status with command # service ssh status

But when we reboot this CT machine, and now try to access it with a new custom port, the server does not respond. But when we try to log in with default Port 22 we get a response to access the server.

Check the status and get the result
Active: inactive (dead) you can see on image ubuntu-20-ssh-dead-status

When we manually start with the command # service ssh start we successfully start the service and back custom port active that we configure early.

In CT version Ubuntu 22.10


In this case, ubuntu any time starting ssh service as you can see on image ubuntu-22-ssh-dead-status

But if we change the config and set again custom Port 2222 like before what you can see on image ubuntu-sshd_config and restart service # service ssh restart we get the same status as nothing changes.


In case when we run Ubuntu as like VM and install from an iso file anything of these problems from above not happening.

Has anyone encountered this problem so far?
 

Attachments

  • ubuntu-20-ssh-dead-status.jpg
    ubuntu-20-ssh-dead-status.jpg
    16.4 KB · Views: 5
  • ubuntu-22-ssh-dead-status.jpg
    ubuntu-22-ssh-dead-status.jpg
    89.4 KB · Views: 6
  • ubuntu-sshd_config.jpg
    ubuntu-sshd_config.jpg
    76.4 KB · Views: 5
If someone's OS like as it Ubuntu above type has a problem configuring SSH with a custom port using and working stable has the container been stopped or rebooted to not back on basic SSH configuration and force only Port 22 to use?

You need to reconfigure your shh with the next steps.

First-stop ssh service
# sudo systemctl disable ssh

After that remove the next packet
# sudo apt-get remove --purge ssh # sudo apt-get remove --purge openssh-server

!!! Do not restart or close the session that you are using in this process !!!

Install the new SSH server with the next command.
# sudo apt install openssh-server # sudo systemctl enable ssh # sudo systemctl status ssh

When you successfully install SSH don’t close the session, because you probably can not access it again, because you need to allow root access if you don't do that you probably get this message when you try to log in enter the root username, and enter a password but not access.

Example
root@Ubuntu:/etc/ssh# reboot login as: root root@Ubuntu.dnshw.net's password: Access denied

To configure this part you need to edit the ssh config with the next command.
# nano etc/ssh/sshd_config

And at that moment you can set up your custom access Port and a little below you can find #PermitRootLogin prohibit-password you need to change to PermitRootLogin yes save and exit in the config file.

After that, you need to restart the ssh service with the next command
# service ssh restart

To check the status and changes use the command.
# service ssh status

Now probably see your custom port active, and now if you want you can restart your server but that is not important.
 
Last edited:
The three lines above your "Port 2222" setting indicate that it might be the wrong place to change that.

https://discourse.ubuntu.com/t/sshd-now-uses-socket-based-activation-ubuntu-22-10-and-later/30189

Socket-activated: "This means that sshd will not be started until an incoming connection request is received."

"On upgrades from Ubuntu 22.04 LTS, users who had configured Port settings or a ListenAddress setting in /etc/ssh/sshd_config will find these settings migrated to /etc/systemd/system/ssh.socket.d/addresses.conf."



So generally there were multiple changes that you might need to read up on in order to configure 22.04/22.10 correctly.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!