LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-11-2013, 11:09 AM   #1
Rogue45
Member
 
Registered: Jun 2012
Posts: 47

Rep: Reputation: Disabled
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?
 
Old 07-11-2013, 11:21 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by Rogue45 View Post
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.
 
1 members found this post helpful.
Old 07-11-2013, 11:22 AM   #3
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
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.
 
1 members found this post helpful.
Old 07-11-2013, 12:23 PM   #4
Rogue45
Member
 
Registered: Jun 2012
Posts: 47

Original Poster
Rep: Reputation: Disabled
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.
 
1 members found this post helpful.
Old 07-11-2013, 12:56 PM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by Rogue45 View Post
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.
 
Old 12-06-2018, 08:28 AM   #6
rgsurfs
LQ Newbie
 
Registered: May 2013
Posts: 18

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

net ads join -U 'user%password'
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Script Password Response es0teric Programming 6 07-31-2008 05:56 PM
Shell script sudo without password prompt under Darwin? lhouk Other *NIX 3 02-08-2008 11:16 AM
password prompt ? wr3ck3d Linux - General 5 03-20-2003 08:54 PM
No Password Prompt hockeydude Linux - General 3 04-18-2001 04:29 AM
no password prompt stroh78 Linux - General 3 01-02-2001 09:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration