[Solved] E: Sub-process /usr/bin/dpkg returned an error code (1)

This error occurred when installing OpenSSL server because the following error occurred during apt get software installation:

liyang@liyang-PC:~$ sudo apt-get install openssh-server
Reading the package list... Done
Analyzing the dependency tree of the package       
Reading status information... Done       
openssh-server is up to date (1:7.7p1-2).
0 packages upgraded, 0 new packages installed, 0 packages to uninstall, and 1 package not upgraded.
1 package has not been fully installed or uninstalled.
Unpacking consumes 0 B of extra space.
Do you wish to continue? [Y/n] Y
Being set up openssh-server (1:7.7p1-2) ...
Job for ssh.service failed because the control process exited with error code.
See "systemctl status ssh.service" and "journalctl -xe" for details.
invoke-rc.d: initscript ssh, action "start" failed.
● ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Mon 2020-03-23 18:19:35 CST; 10ms ago
  Process: 8046 ExecStart=/usr/sbin/sshd -D $SSHD_OPTS (code=exited, status=1/FAILURE)
  Process: 8034 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
 Main PID: 8046 (code=exited, status=1/FAILURE)
dpkg: Handle openssh-server (--configure) pack error:
 installed openssh-server package post-installation script subprocess returned error exit status 1
An error occurred during processing.
 openssh-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

Solution:

1. The info folder is now renamed

sudo mv /var/lib/dpkg/info /var/lib/dpkg/info.bk

2. Create a new info folder

sudo mkdir /var/lib/dpkg/info

3. Installation and repair

sudo apt-get update
sudo apt-get install -f

4. After performing the previous step, some files are generated in the info folder. Now move all these files to the info.bk folder

sudo mv /var/lib/dpkg/info/* /var/lib/dpkg/info.bk

5. Delete your new info folder

sudo rm -rf /var/lib/dpkg/info

6. Restore the original info folder and modify the name

sudo mv /var/lib/dpkg/info.bk /var/lib/dpkg/info

Similar Posts: