Automatically Connect the Database

If you want the database to connect every time you launch msfconsole, you can copy the database configuration file and move it to the .msf4 directory. The .msf4 directory is a hidden folder in the home directory that is automatically created by the Metasploit installer. If you cloned Metasploit from GitHub, you will need to manually create the folder.

To copy database.yml to the .msf folder, run the following command:

1
cp /opt/framework/config/database.yml /root/.msf4/