LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   script a response to a password prompt (https://www.linuxquestions.org/questions/linux-newbie-8/script-a-response-to-a-password-prompt-4175469288/)

Rogue45 07-11-2013 11:09 AM

script a response to a password prompt
 
I have a script that joins a linux user to AD. It runs the net ads join -U userid@domain and it always prompts for a password. I would like to store that password as a variable and provide it as input to the net ads join command that way the script doesn't stop for user input. Is that possible?

TB0ne 07-11-2013 11:21 AM

Quote:

Originally Posted by Rogue45 (Post 4988491)
I have a script that joins a linux user to AD. It runs the net ads join -U userid@domain and it always prompts for a password. I would like to store that password as a variable and provide it as input to the net ads join command that way the script doesn't stop for user input. Is that possible?

Yes. Read the man page on the net command. Pay particular attention to the -U flag, since it tells you how to specify a password:
Quote:

Originally Posted by net man page
[RPC|ADS] JOIN [TYPE] [-U username[%password]] [createupn=UPN] [createcomputer=OU] [options]

Putting "-U username%mypassword@domain" is what you need.

Firerat 07-11-2013 11:22 AM

Code:

man net
gets you the manual

Quote:

Originally Posted by man net
Code:

[RPC|ADS] JOIN [TYPE] [-U username[%password]] [createupn=UPN] [createcomputer=OU] [options]
      Join a domain. If the account already exists on the server, and [TYPE] is MEMBER, the
      machine will attempt to join automatically. (Assuming that the machine has been created in
      server manager) Otherwise, a password will be prompted for, and a new account may be
      created.

      [TYPE] may be PDC, BDC or MEMBER to specify the type of server joining the domain.

      [UPN] (ADS only) set the principalname attribute during the join. The default format is
      host/netbiosname@REALM.

      [OU] (ADS only) Precreate the computer account in a specific OU. The OU string reads from
      top to bottom without RDNs, and is delimited by a '/'. Please note that '\' is used for
      escape by both the shell and ldap, so it may need to be doubled or quadrupled to pass
      through, and it is not used as a delimiter.



Rogue45 07-11-2013 12:23 PM

Whoops i saw that but thought the % was Windows or something. Thanks guys. i used net ads join -U ${ADMIN_ACCT}@${DOMAIN}%${PASSWORD} so i could pass all the variables in from command line.

TB0ne 07-11-2013 12:56 PM

Quote:

Originally Posted by Rogue45 (Post 4988532)
Whoops i saw that but thought the % was Windows or something. Thanks guys. i used net ads join -U ${ADMIN_ACCT}@${DOMAIN}%${PASSWORD} so i could pass all the variables in from command line.

Thanks for posting back the solution that worked for you.

rgsurfs 12-06-2018 08:28 AM

I had to put mine in single quote, most likely due to special characters in the password

net ads join -U 'user%password'


All times are GMT -5. The time now is 11:24 AM.