Non-interactive add-user.sh does not give secre value

Latest response

Hi,

We have a problem where we are calling add-user.sh from another script non-interactively and although it creates the user as desired but unlike interactive mode it does not provide the secret value at the end when you answer yes for the question "Is this new user going to be used for one AS process to connect to another AS process?"(this section itself does not come up). Is there a way solution to this problem where I can use the add-user.sh script in non-interactive mode but also obtain the secret value ?

Responses

Hi,

please check this link - https://docs.jboss.org/author/display/AS71/add-user+utility

specially sections called Non-Interactive Mode

//Zdenek

The link does say on how to create a management user in non-interactive mode but it does not solve my problem where I need to obtain the secret value to be used for connecting to another jboss server as the non-interactive mode only creates the management user but does not provide the secret value.

There is an application user example below, if it helps. If not, you need to dig into the script and see how it calls the question and possibly use expect or something similar to send the yes answer to the script

//Zdenek

Is there any solution for the original question? Non-interactive mode is not displaying secret value for the management user. I am yet to dig into adduser.sh script. If there is any solution already available please post here.

Hi Joseph,

I have the same issue with non-interactive mode. One possible solution I found by looking the source code is the following:

The class generating the secret value is "org.jboss.as.domain.management.security.adduser.DisplaySecret" and the method that generates the code, does a Base64 encoding on the password only.

 public State execute() {
        String pwdBase64 = Base64.encodeBytes(stateValues.getPassword().getBytes());
        theConsole.printf(MESSAGES.secretElement(pwdBase64));
        theConsole.printf(NEW_LINE);

        // This is now the final state so return null.
        return null;
    }

I am thinking of writing a custom utility to encode the password and then use it in my hosts.xml. The Base64 implementation is org.jboss.util.Base64 and not java.util.Base64.

I hope this helps.

Kind regards,

Petros

Hi,

Please create a script as mentioned below.

Script Start

./add-user.sh $1 $2

sleep 3

echo -n $2|base64

Script End

Run the script as ./script_name username password