I encountered an error message “ruby: error while loading shared libraries: libcrypt.so.1: cannot open shared object file: No such file or directory” after installation of Metasploit framework when attempting to start its console with the command msfdb init. On further analysis it seems the issue is caused by the missing ruby library on the system, called libcrypt.so.

To fix the issue we must install the libxcrypt-compat package which provides the library. On RHEL based system, this can be installed by running the commands below.

sudo yum install libxcrypt-compat

For Ubuntu

sudo apt install libcrypt1

On Debian

sudo apt update && sudo apt install libxcrypt-compat

Confirm successful installation of “libcrypt” library.

## Ubuntu ###
$ find /usr -name  libcrypt.so.1
/usr/lib/x86_64-linux-gnu/libcrypt.so.1

### Fedora ###
$ find /usr -name  libcrypt.so.1
/usr/lib64/libcrypt.so.1

I was then able to run the application without the issue.

### Before ###
$ msfdb init
ruby: error while loading shared libraries: libcrypt.so.1: cannot open shared object file: No such file or directory

### After library installation ###
$ sudo msfdb init
Running the 'init' command for the database:
Creating database at /home/jkmutai/.msf4/db
Creating db socket file at /tmp
Starting database at /home/jkmutai/.msf4/db...server starting
success
Creating database users
Writing client authentication configuration file /home/jkmutai/.msf4/db/pg_hba.conf
Stopping database at /home/jkmutai/.msf4/db
Starting database at /home/jkmutai/.msf4/db...server starting
success
Creating initial database schema
Database initialization successful

The libcrypt contains functions used for cryptographic operations. It is mostly used in password hashing by many applications and is major dependency on Linux.

LEAVE A REPLY

Please enter your comment!
Please enter your name here