13 Replies Latest reply: Mar 27, 2012 9:02 AM by Pratik Parikh RSS

    jboss-admin.sh user and password

    Carlos Oliva Novice

      How can I pass the user and password in the CLI to shutdown JBoss?  I want to add a user and password to the native interface but if I do that the shutdown command will require a user and password.  The documentation lacks information to pass the user and password in the connect command.  There is an old discussion thread about this in which they implemented some flags that can be passed in a beta version of JBoss.  Nevertheless, it is difficult to discern how one is supposed to pass these flags or if the oprion is still availabel in the latest version of JBoss7

        • 1. Re: jboss-admin.sh user and password
          Darran Lofthouse Master

          The option to pass in those values on the command line will be from JBoss 7.1.0.Beta1

          • 2. Re: jboss-admin.sh user and password
            Carlos Oliva Novice

            Thank you for your response.  Can user and password be used in 7.0.2 to secure the native interface and shutdown from the command line?

            • 3. Re: jboss-admin.sh user and password
              Radoslav Husar Master

              Hi Carlos,

               

              look in this directory where you find 2 scripts to secure your console:

              [rhusar@rhusar Download]$ ls -1 jboss-as-7.0.2.Final/bin/scripts/

              secure-host-controller-mgmt.cli

              secure-standalone-mgmt.cli

              Open them up for readme information on how to secure it.

               

              If you want to use the user and password from CLI you can build the latest snapshot youself and use that.

               

              Rado

              • 4. Re: jboss-admin.sh user and password
                Carlos Oliva Novice

                Thank you for your response.  I understand what options you are presenting.  For the time being I will probably leave the native interface without a user and password.  We will probably wait for the version 7.1.x that implements the user and password.

                • 5. Re: jboss-admin.sh user and password
                  Fred Welland Newbie

                  I am kinda disappointed with jboss as 7;  all around it just seems undercooked.

                   

                  Here is my workaround for this issue (works on rh/linux -- I have this as a 'task' under some of my jenkins jobs):

                   

                  #!/bin/ksh

                  ##

                  ## Helper to deploy a module to JBOS AS 7

                  ##

                     

                  SVC_GRP=$2

                  PKG=$1

                   

                  JBOSS_HOME=/opt/jboss

                  JBOSS_DC=`cat ${HOME}/.jboss_dc_params |head -n 1`

                  UZER=`cat ${HOME}/.jboss_dc_params |head -n 2 | tail -n 1`

                  PASS=`cat ${HOME}/.jboss_dc_params |tail -n 1`

                  out_file="$$.out"

                  ${JBOSS_HOME}/bin/jboss-admin.sh --connect --controller="${JBOSS_DC}" 2>&1 >"${out_file}" |&

                  print -p -- "${UZER}"

                  print -p -- "${PASS}"

                  print -p -- "deploy ${PKG} --force --server-groups ${SVC_GRP}"

                  print -p -- "quit"

                  wait

                  cat "${out_file}"

                  grep -q "deployed successfully" "${out_file}" >/dev/null

                  rc=$?

                  rm -f ${out_file}

                  if [ ${rc} -ne 0  ]  ;  then

                          echo "ATTENTION:   deployment likely didn't work!"

                  fi

                  exit ${rc}

                  • 6. Re: jboss-admin.sh user and password
                    Darran Lofthouse Master

                    Don't worry for AS 7.1.0 Beta1 this issue will be resolved, we are just in the process of adding a new mechanism to silently authenticate the CLI against the AS server when running as the same user as the AS.

                    • 7. Re: jboss-admin.sh user and password
                      Carlos Oliva Novice

                      Thank you Fred for the ksh script.  I am trying to replicate it with bash but i seem to have some problem creating a co-process in bash.  WOuld you have any suggestions to replace the |& in bash?

                      • 8. Re: jboss-admin.sh user and password
                        Fred Welland Newbie

                        wow,   Interesting... won't have guessed that.   I just switched from

                        #!/bin/ksh to #!/bin/bash and got this:

                         

                        /home/jboss/scripts/deploy.sh: line 17: syntax error near unexpected token `&'

                        /home/jboss/scripts/deploy.sh: line 17: `${JBOSS_HOME}/bin/jboss-admin.sh --connect --controller="${JBOSS_DC}" 2>&1 >"${out_file}" |&'

                         

                         

                        Which I guess is what you get.

                         

                        Lemm take a look...

                        • 9. Re: jboss-admin.sh user and password
                          Carlos Oliva Novice

                          Hi Fred,  The |& is for the ksh shell; not bash.  I think that one must use exec and redirect from a file or variable to the standard input of the jboss-admin.sh.  I am just dabbling on re-directions so it would be nice to hear from a bash wizard out there.  This should be possible in bash.

                          • 10. Re: jboss-admin.sh user and password
                            Fred Welland Newbie

                            yeah indeed bash is alergic to '|&'    I think there are about a dozen ways to skin this....

                             

                            The version below, makes a co-process that just does a few echo statements to STDOUT.   This output  piped to the jboss admin.  The 'wait' isn't needed anymore (or so I think).     

                             

                            Come to think of it, I like this version better -- it seems a bit more clear that you are sending the echo output as input 'into' jboss-admin.   The ksh version doesn't have this implication.  Normally when I see a '|' ; I usually think 'stuff from left is going into program on right' (but there is no program on the right!).    With the |& you are making an unamed pipe that is being written too by print -p ; not as obvious imho...

                             

                            This version seesm to work on Red Hat Enterprise Linux Server release 5.7 (Tikanga) (2.6.18-274.7.1.el5)  and

                            GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)

                            Copyright (C) 2005 Free Software Foundation, Inc.

                             

                            (it worked from jenkins too...)

                             

                            HTH...

                            ------------------

                            #!/bin/bash

                            ##

                            ## Helper to deploy a module to JBOS AS 7

                            ##

                             

                            SVC_GRP=$2

                            PKG=$1

                             

                             

                            JBOSS_HOME=/opt/jboss

                            JBOSS_DC=`cat ${HOME}/.jboss_dc_params |head -n 1`

                            UZER=`cat ${HOME}/.jboss_dc_params |head -n 2 | tail -n 1`

                            PASS=`cat ${HOME}/.jboss_dc_params |tail -n 1`

                            out_file="$$.out"

                            ( \

                            echo "${UZER}"

                            echo "${PASS}"

                            echo "deploy ${PKG} --force --server-groups ${SVC_GRP}"

                            echo "quit" 

                            ) | ${JBOSS_HOME}/bin/jboss-admin.sh --connect --controller="${JBOSS_DC}" 2>&1 >"${out_file}"

                            wait

                            cat "${out_file}"

                            grep -q "deployed successfully" "${out_file}" >/dev/null

                            rc=$?

                            rm -f ${out_file}

                            if [ ${rc} -ne 0  ]  ;  then

                                      echo "ATTENTION:   deployment likely didn't work!"

                            fi

                            exit ${rc}

                            • 11. Re: jboss-admin.sh user and password
                              Carlos Oliva Novice

                              Thank you Fred.  I will try this in my shutdown script for JBoss7.  I imagine that I can change the jboss-admin.sh part to:

                              $JBOSS_HOME/bin/jboss-admin.sh --connect command=:shutdown

                              • 12. Re: jboss-admin.sh user and password
                                Carlos Oliva Novice

                                Thank you Fred.  The subshell worked fine for me to create a shutdown and reload scripts with a user and password for the mative interface.

                                • 13. Re: jboss-admin.sh user and password
                                  Pratik Parikh Newbie

                                  Carlos can you please post your solution. I am looking for the same thing. Many thanks in advance.

                                   

                                  Regards,

                                  TiKi