Ubuntu 18.04: libcrypto.so.1.0.0: cannot open shared object file: No such file or directory

This is the output of

sudo apt-get -f install

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer 
required:
linux-modules-4.15.0-33-generic linux-modules-4.15.0-34-generic
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
linux-image-4.15.0-33-generic linux-image-4.15.0-34-generic
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
7 not fully installed or removed.
After this operation, 16.6 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 237395 files and directories currently 
installed.)
Removing linux-image-4.15.0-33-generic (4.15.0-33.36) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-4.15.0-33-generic
/etc/kernel/postrm.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
/etc/grub.d/bin/grubcfg_proxy: error while loading shared libraries: 
libcrypto.so.1.0.0: cannot open shared object file: No such file or 
directory
Found Windows Boot Manager on 
/dev/sda1@/EFI/Microsoft/Boot/bootmgfw.efi
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 
127
dpkg: error processing package linux-image-4.15.0-33-generic (-- 
remove):
installed linux-image-4.15.0-33-generic package post-removal script 
subprocess returned error exit status 1
Removing linux-image-4.15.0-34-generic (4.15.0-34.37) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-4.15.0-34-generic
/etc/kernel/postrm.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
/etc/grub.d/bin/grubcfg_proxy: error while loading shared libraries: 
libcrypto.so.1.0.0: cannot open shared object file: No such file or 
directory
Found Windows Boot Manager on 
/dev/sda1@/EFI/Microsoft/Boot/bootmgfw.efi
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code     
127
dpkg: error processing package linux-image-4.15.0-34-generic (-- 
remove):
installed linux-image-4.15.0-34-generic package post-removal script 
subprocess returned error exit status 1
Errors were encountered while processing:
linux-image-4.15.0-33-generic
linux-image-4.15.0-34-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

https://i.stack.imgur.com/WaZPo.png

Edit: the output of

sudo locate libcrypto.so.1.0.0

/snap/core/5897/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
/snap/core/6130/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
/snap/core/6350/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
/snap/core18/594/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
/snap/core18/677/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
/snap/gnome-3-26-1604/70/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
/snap/gnome-3-26-1604/74/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
/snap/kde-frameworks-5-core18/26/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0


apt list libssl1*

Listing... Done
libssl1.0-dev/bionic-updates,bionic-security 1.0.2n-1ubuntu5.2 amd64
libssl1.0.0/bionic-updates,bionic-security,now 1.0.2n-1ubuntu5.2 amd64 [installed]
libssl1.1/bionic-updates,bionic-security,now 1.1.0g-2ubuntu4.3 amd64 [installed]

Solution 1:

First locate where is your library:

sudo locate libcrypto.so.1.0.0

Then copy that into your /usr/lib/ folder:

sudo cp /snap/gnome-3-26-1604/82/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 /usr/lib/

Solution 2:

Please check that what version of libssl installed on your system, In case of mine on Ubuntu 19.04 there was libssl1.1 instead of required libssl1.0. So I have to install software that comes with libssl1.0. Best part is ubuntu comes with snap to install such softwares like Termius. Then fix the problem as answered by "Rodrigo".

Locate the installed path:

sudo locate libcrypto.so.1.0.0

Then either add the discovered path to path variable:

export PATH=<discovered path>:$PATH

Or add libraries to pre included path:

sudo ln -s <discovered path> /usr/lib/

Solution 3:

I experienced the same error as the OP, after using Ubuntu Software Updater to update from 18.04 to 19.04.

When the update was just about done an was removing old unused linux kernels, the OP's error occurred during a grub configuration step driven by the Updater.

Searching for a remediation I found the OP's post and tried the same steps. As I improvised and found a workaround that was clean, I post it here:

lnx:~$ sudo apt-get install -f
[sudo] password for john: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  breeze-cursor-theme fonts-hack fonts-hack-ttf oxygen-icon-theme
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  linux-image-4.15.0-58-generic linux-image-4.15.0-60-generic
0 to upgrade, 0 to newly install, 2 to remove and 1 not to upgrade.
2 not fully installed or removed.
After this operation, 16.7 MB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 205548 files and directories currently installed.)
Removing linux-image-4.15.0-58-generic (4.15.0-58.64) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-4.15.0-58-generic
/etc/kernel/postrm.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.0.0-32-generic
Found initrd image: /boot/initrd.img-5.0.0-32-generic
Found linux image: /boot/vmlinuz-4.15.0-66-generic
Found initrd image: /boot/initrd.img-4.15.0-66-generic
/etc/grub.d/bin/grubcfg_proxy: error while loading shared libraries: libcrypto.so.1.0.0: cannot open shared object file: No such file or directory
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 127
dpkg: error processing package linux-image-4.15.0-58-generic (--remove):
 installed linux-image-4.15.0-58-generic package post-removal script subprocess returned error exit status 1
Removing linux-image-4.15.0-60-generic (4.15.0-60.67) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-4.15.0-60-generic
/etc/kernel/postrm.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
/etc/grub.d/bin/grubcfg_proxy: error while loading shared libraries: libcrypto.so.1.0.0: cannot open shared object file: No such file or directory
Found linux image: /boot/vmlinuz-5.0.0-32-generic
Found initrd image: /boot/initrd.img-5.0.0-32-generic
Found linux image: /boot/vmlinuz-4.15.0-66-generic
Found initrd image: /boot/initrd.img-4.15.0-66-generic
/etc/grub.d/bin/grubcfg_proxy: error while loading shared libraries: libcrypto.so.1.0.0: cannot open shared object file: No such file or directory
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 127
dpkg: error processing package linux-image-4.15.0-60-generic (--remove):
 installed linux-image-4.15.0-60-generic package post-removal script subprocess returned error exit status 1
Errors were encountered while processing:
 linux-image-4.15.0-58-generic
 linux-image-4.15.0-60-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)
W: Operation was interrupted before it could finish

So libcrypto.so.1.0.0 is not found in an expected location by grubcfg_proxy. Following the advice of a respondent to the OP:

lnx:~$ sudo locate libcrypto.so.1.0.0
/snap/core/7713/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
/snap/core/7917/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
/snap/core18/1192/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
/snap/core18/1223/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
/snap/gnome-3-26-1604/92/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
/snap/gnome-3-26-1604/97/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0

Which I followed up with:

lnx:~$ for l in $(sudo locate libcrypto.so.1.0.0); do md5sum $l; done
829091982233166cdaa55b41fb353609  /snap/core/7713/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
829091982233166cdaa55b41fb353609  /snap/core/7917/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
18403538a12facf8aced1dcfcccef1ba  /snap/core18/1192/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
18403538a12facf8aced1dcfcccef1ba  /snap/core18/1223/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
829091982233166cdaa55b41fb353609  /snap/gnome-3-26-1604/92/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
829091982233166cdaa55b41fb353609  /snap/gnome-3-26-1604/97/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
md5sum: /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0: No such file or directory

Ah ha! /usr/lib/x86_64-linux-gnu/ must be the location where grubcfg_proxy needs to find libcrypto.so.1.0.0.

Which of the others to cp -p, ln or ln -s to the expected location? The md5 signatures tell me which files are the same bytewise content. Are any the same actual files?

lnx:~$ for l in $(sudo locate libcrypto.so.1.0.0); do ls -il $l; done
2134 -rw-r--r-- 1 root root 2365952 Feb 27  2019 /snap/core/7713/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
2134 -rw-r--r-- 1 root root 2365952 Feb 27  2019 /snap/core/7917/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
5689 -rw-r--r-- 1 root root 2357760 Feb 27  2019 /snap/core18/1192/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
5690 -rw-r--r-- 1 root root 2357760 Feb 27  2019 /snap/core18/1223/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
165 -rw-r--r-- 1 root root 2365952 Feb 27  2019 /snap/gnome-3-26-1604/92/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
165 -rw-r--r-- 1 root root 2365952 Feb 27  2019 /snap/gnome-3-26-1604/97/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
ls: cannot access '/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0': No such file or directory

The inode numbers in column 1 show which instances of libcrypto.so.1.0.0, and the hard link count of 1 in column 3 shows symlinks are involved in providing the multiple paths.

I decide I just need to cp -p one of the files to the correct location to get past the problem. Which of the two different md5 signatures / bytewise different content options do I choose?

After some googling I find that /snap/core/... is based on ubuntu 16.04, and /snap/core18/... is based on ubuntu 18.04.

I am leaning toward /snap/core18/.../libcrypto.so.1.0.0.

It turns out after some checking that /snap/core18/.../libcrypto.so.1.1 and /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 are the same bytewise, so I decide to keep /usr/lib/x86_64-linux-gnu/libcrypto.so.1.* all ubuntu 18.04.

I copy the file into place and run sudo apt-get install -f again. Voila! grubcfg_proxy is happy and the old kernels are removed.

lnx:~$ sudo cp -p /snap/core18/1223/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
lnx:~$ sudo apt-get install -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  breeze-cursor-theme fonts-hack fonts-hack-ttf oxygen-icon-theme
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  linux-image-4.15.0-58-generic linux-image-4.15.0-60-generic
0 to upgrade, 0 to newly install, 2 to remove and 1 not to upgrade.
2 not fully installed or removed.
After this operation, 16.7 MB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 205548 files and directories currently installed.)
Removing linux-image-4.15.0-58-generic (4.15.0-58.64) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-4.15.0-58-generic
/etc/kernel/postrm.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.0.0-32-generic
Found initrd image: /boot/initrd.img-5.0.0-32-generic
Found linux image: /boot/vmlinuz-4.15.0-66-generic
Found initrd image: /boot/initrd.img-4.15.0-66-generic
Found linux image: /boot/vmlinuz-5.0.0-32-generic
Found initrd image: /boot/initrd.img-5.0.0-32-generic
Found linux image: /boot/vmlinuz-4.15.0-66-generic
Found initrd image: /boot/initrd.img-4.15.0-66-generic
Found Windows 10 on /dev/sda1
Found Windows 10 on /dev/sda1
Found linux image: /boot/vmlinuz-5.0.0-32-generic
Found initrd image: /boot/initrd.img-5.0.0-32-generic
Found linux image: /boot/vmlinuz-4.15.0-66-generic
Found initrd image: /boot/initrd.img-4.15.0-66-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
Found Windows 10 on /dev/sda1
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
done
Removing linux-image-4.15.0-60-generic (4.15.0-60.67) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-4.15.0-60-generic
/etc/kernel/postrm.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.0.0-32-generic
Found initrd image: /boot/initrd.img-5.0.0-32-generic
Found linux image: /boot/vmlinuz-4.15.0-66-generic
Found initrd image: /boot/initrd.img-4.15.0-66-generic
Found linux image: /boot/vmlinuz-5.0.0-32-generic
Found initrd image: /boot/initrd.img-5.0.0-32-generic
Found linux image: /boot/vmlinuz-4.15.0-66-generic
Found initrd image: /boot/initrd.img-4.15.0-66-generic
Found Windows 10 on /dev/sda1
Found Windows 10 on /dev/sda1
Found linux image: /boot/vmlinuz-5.0.0-32-generic
Found initrd image: /boot/initrd.img-5.0.0-32-generic
Found linux image: /boot/vmlinuz-4.15.0-66-generic
Found initrd image: /boot/initrd.img-4.15.0-66-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
Found Windows 10 on /dev/sda1
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
done

I can now proceed to update from ubuntu 19.04 to 19.10, with only a "crufty" /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 from 18.04 lying around on my disk to perhaps help future package management problems. First, for good measure:

john@jameskb-lnx:~$ sudo apt-get install -f
[sudo] password for john: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  breeze-cursor-theme fonts-hack fonts-hack-ttf oxygen-icon-theme
Use 'sudo apt autoremove' to remove them.

Looks like I can clean up a little more ;)