Script to request username and password

maiksanftenberg
Contributor II

Hi all.

I'm looking for a script that requests the user to input his username and password. If possible the user should type the password twice and both should be compared.

Both values should be stored for a later local account creation e.g.

Does somebody have something at hand?

5 REPLIES 5

ammonsc
Contributor II

Wouldn't this cause the users username and password to be sent in plain text. I am not sure that you really should do that. I would check with you network security team first.

ammonsc
Contributor II

You could use something along the lines of...

#!/bin/sh

Username ="$(osascript -e 'Tell application "System Events" to display dialog "Enter your username:" default answer ""' -e 'text returned of result' 2>/dev/null)"

Password="$(osascript -e 'Tell application "System Events" to display dialog "Enter your password:" default answer ""' -e 'text returned of result' 2>/dev/null)"

Password2="$(osascript -e 'Tell application "System Events" to display dialog "Enter your password again:" default answer ""' -e 'text returned of result' 2>/dev/null)"

Then you would need add in the script how you want to output said answers. In the log? In a text file?

With that said this will send the information in plaintext and I highly suggest to NOT do that.

znilsson
Contributor II

Without knowing your situation or what you've researched so far - have you looked into NoMAD Login?

NoMADLogin-AD

cinchnetops
New Contributor

This script has a similar method as already posted, and also uses the "hidden answer" option and passes it to an expect block for later use. As @ammonsc mentioned, you'd definitely want to make sure this meets your security requirements:

https://github.com/JAMFSupport/FileVault2_Scripts/blob/master/reissueKey.sh

maiksanftenberg
Contributor II

Thanks all...
I'm aware of the password been passed in plain text or been used within the script in plain text.
We might look into another option to do this.