I had ssh installed and was working fine but then it stopped suddenly.So I tried to reinstall using sudo apt-get install --reinstall openssh-serverbut it seemed that the already active systemctl was interfering (according to chatGPT and the solution it gave was to stop it so I did and then tried to reinstall.But I am still getting this error
$ sudo apt install openssh-server
Building dependency tree... DoneReading state information... Doneopenssh-server is already the newest version (1:8.9p1-3ubuntu0.6).The following packages were automatically installed and are no longer required: libdecor-0-0 libdecor-0-plugin-1-cairo libdouble-conversion3 libfluidsynth3 libinstpatch-1.0-2 libmd4c0 libmodplug1 libopusfile0 libpcre2-16-0 libportmidi0 libqt5core5a libqt5dbus5 libqt5gui5 libqt5network5 libqt5positioning5 libqt5printsupport5 libqt5qml5 libqt5qmlmodels5 libqt5qmlworkerscript5 libqt5quick5 libqt5sensors5 libqt5svg5 libqt5webchannel5 libqt5webkit5 libqt5widgets5 libqt5x11extras5 libsdl2-2.0-0 libsdl2-image-2.0-0 libsdl2-mixer-2.0-0 libsdl2-ttf-2.0-0 libxcb-xinput0 python3-numpy python3-polib python3-pygame qml-module-qt-labs-folderlistmodel qml-module-qt-labs-settings qml-module-qtgraphicaleffects qml-module-qtqml qml-module-qtqml-models2 qml-module-qtquick-controls qml-module-qtquick-dialogs qml-module-qtquick-layouts qml-module-qtquick-privatewidgets qml-module-qtquick-window2 qml-module-qtquick2 qt5-gtk-platformtheme qttranslations5-l10n timgm6mb-soundfontUse 'sudo apt autoremove' to remove them.0 to upgrade, 0 to newly install, 0 to remove and 39 not to upgrade.1 not fully installed or removed.After this operation, 0 B of additional disk space will be used.Do you want to continue? [Y/n] ySetting up openssh-server (1:8.9p1-3ubuntu0.6) ...Not replacing deleted config file /etc/ssh/sshd_configdpkg: error processing package openssh-server (--configure): installed openssh-server package post-installation script subprocess returned error exit status 1Errors were encountered while processing: openssh-serverE: Sub-process /usr/bin/dpkg returned an error code (1)
and
$ sudo systemctl start ssh
See "systemctl status ssh.service" and "journalctl -xeu ssh.service" for details.
$ sudo systemctl enable ssh
Executing: /lib/systemd/systemd-sysv-install enable ssh
Please help I have exhausted myself trying to connect to this server