openssh-server post-installation script error (exit status 10) and SSH not working
https://askubuntu.com/questions/1566463/openssh-server-post-installation-script-error-exit-status-10-and-ssh-not-worki
I’m encountering an issue where openssh-server fails during configuration, and SSH is currently not working on my system.
This error appears during package operations, even when I’m not explicitly trying to install openssh-server.
What happens
During apt/dpkg operations, I see:
Setting up openssh-server (1:9.6p1-3ubuntu13.16) ...
dpkg: error processing package openssh-server (--configure):
installed openssh-server package post-installation script subprocess returned error exit status 10
Errors were encountered while processing:
openssh-server
What I’ve tried
- Re-running configuration:
sudo dpkg --configure -a
Same error persists.
- Running the post-install script manually with debugging:
sudo bash -x /var/lib/dpkg/info/openssh-server.postinst configure
This didn’t produce any obvious error output, and the last line is `exec /usr/share/debconf/frontend /var/lib/dpkg/info/openssh-server.postinst configure which tells me that something to do with package configuration is failing.
- Regenerating SSH host keys:
sudo rm -f /etc/ssh/ssh_host_*
sudo ssh-keygen -A
Keys were generated successfully, but the issue remains.
- Restore ssh config:
sudo cp /usr/share/openssh/sshd_config /etc/ssh/sshd_config
Observations
SSH into this machine is not functioning.
The openssh-server package is broken.
The post-installation script consistently exits with status 10.
Research
I found that post-installation script failures can be caused by misconfiguration or missing files, but most solutions suggest reinstalling or purging the package. I haven’t found a clear explanation for exit status 10 specifically or how to resolve it without risking further issues.
Previously, I have used this sequence of commands to fix similar errors:
rm -rf /var/lib/dpkg/info/<packagename>* (in this case openssh*)
dpkg --configure -a
Fix package post-installation script subprocess returned error exit status 10 for libpaper1:amd64
Error reinstalling isc-dhcp-server "post installation script returned error exit status 255"
Like in the above posts, which has fixed the error temporarily, but probably messed up the dpkg package lists or something.
The issue keeps coming back, it's a different package or packages every time so it seems like an issue with dpkg or a corrupt filesystem.
Any ideas what is causing this issue, and how I can resolve it without reinstalling the system?
Update: I got ssh server working again, but still seeing the error on install/configure. getting closer. these are the commands that fixed it and my logic behind them
sudo cp /usr/share/openssh/sshd_config /etc/ssh/sshd_config
-- there was no sshd config until i copied it from here
--- then uncommented the host keys in that file, and generated them. made sshd user
grep -n "HostKey" /etc/ssh/sshd_config
2140 ls -l /etc/ssh/sshd_config.d
2141 sshd -T | grep hostkey
2142 sudo nano /etc/ssh/sshd_config
2143 sshd -t
2145 ls -l /etc/ssh/ssh_host_*
2146 namei -l /etc/ssh/ssh_host_rsa_key
2147 sudo ssh-keygen -lf /etc/ssh/ssh_host_rsa_key
2148 sshd -T | head -50
2149 lsattr /etc/ssh/ssh_host_rsa_key
2150 mount | grep " / "
2151 sudo rm -f /etc/ssh/ssh_host_*
2152 sudo ssh-keygen -A
2153 sudo ls -l /etc/ssh/ssh_host_*
2154 sudo /usr/sbin/sshd -t -f /etc/ssh/sshd_config
2155 getent passwd sshd
2156 id sshd
--- no sshd user??
2157 sudo adduser --system --no-create-home --group sshd
2158 getent passwd sshd
2159 sudo sshd -t -f /etc/ssh/sshd_config
2161 sudo mkdir -p /run/sshd
2162 sudo chmod 755 /run/sshd
2163 sudo sshd -t -f /etc/ssh/sshd_config
2164 sudo systemctl restart ssh
2165 systemctl status ssh --no-pager
2166 sudo dpkg --configure -a
2167 sudo apt -f install
--- still seeing the error here but the server is up and i can connect from another machine
edit:
ssh has been working fine for weeks, now seeing the same error with libreoffice (I haven't installed them recently, but I did a package upgrade).
Setting up libreoffice-base (4:24.2.7-0ubuntu0.24.04.5) ...
dpkg: error processing package libreoffice-base (--configure):
installed libreoffice-base package post-installation script subprocess returned error exit status 10
Setting up libreoffice-math (4:24.2.7-0ubuntu0.24.04.5) ...