Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate settings-security.xml file for maven password encryption

I want to encrypt my Apache Archiva server password using maven password encryption.

I did:

mvn --encrypt-master-password 12345

Fine. I got an encrypted password inside brackets. Then:

mvn --encrypt-password 12345

Maven complains:

[ERROR] Error executing Maven.
[ERROR] java.io.FileNotFoundException: /home/myUserName/.m2/settings-security.xml (No such file or directory)
[ERROR] Caused by: /home/myUserName/.m2/settings-security.xml (No such file or directory)

I understand that I should put my encrypted master password in the file settings-security.xml, but it does not exist at the default location and maven is not able to generate it.

What should be the content of this configuration file? How to generate it?

like image 672
jvtrudel Avatar asked Jul 24 '18 16:07

jvtrudel


People also ask

How do I generate encrypted password for Maven settings XML?

Use the command mvn --encrypt-master-password to generate a master password. Remember this password.

Where is Maven settings XML?

The Maven settings file, settings. xml , is usually kept in the . m2 directory inside your home directory.


1 Answers

mvn --encrypt-master-password does not create a file settings-security.xml. You have to do it yourself.

So the procedure is:

  1. Use the command mvn --encrypt-master-password to generate a master password. Remember this password.
  2. Create a new file settings-security.xml in ${user.home}/.m2/. For example, on Mac OS X or Ubuntu as ~/.m2/settings-security.xml.

Write into this file:

<settingsSecurity>
  <master>OUTPUT OF THE COMMAND: mvn --encrypt-master-password</master>
</settingsSecurity>

e.g.:

<settingsSecurity>
  <master>{jSMOWnoPFgsHVpMvz5VrIt5kRbzGpI8u+9EF1iFQyJQ=}</master>
</settingsSecurity>

After that the maven encrypt command works on the command line:

mvn --encrypt-password

As mentioned by khmarbaise, more detailed information can be found here: https://maven.apache.org/guides/mini/guide-encryption.html

like image 69
secf00tprint Avatar answered Sep 19 '22 19:09

secf00tprint