LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 08-09-2009, 03:51 PM   #1
loopstr
LQ Newbie
 
Registered: Aug 2009
Location: Denmark
Posts: 4

Rep: Reputation: 0
Bash script predefined user input


Hello all

Its my first post here so please be gentle to me

I have a script im having some problems with, what I need is to have the system generate a random password for me and use that password when creating new users to it.

System is Debian Lenny and script is in bash.

The program is znc. I have made it so that it will generate the random password on the shell but the problem is to use it in the bnc software. To make a password there the command is znc --makepass and look like this:

debian# znc --makepass
[ ?? ] Enter Password:
[ ?? ] Confirm Password:
[ ** ] Use this in the <User> section of your config:
[ ** ] Pass = md5#9463a1389d1454b139b610f032ab4c74#WemSsk6USR0+51V-ZKXh#

My question is now if it would be possible to put in the script so it would "answer" when it need those passwords ? the random password that is generated is in a variable called $setpass and is NOT crypted.

Or is there any other software that would be able to generate that md5 string for me ?


Sorry for my bad english and thanks in advance
 
Old 08-09-2009, 07:00 PM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,557
Blog Entries: 28

Rep: Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178Reputation: 1178
Sorry -- I read your post 3 times and I still don't know what you want to do. Could you give some more detail, especially about "it will generate the random password on the shell but the problem is to use it in the bnc software"?

You script znc to create a password and you get that password into a shellscript variable? Then you want to make an md5sum from it?
 
Old 08-09-2009, 07:15 PM   #3
loopstr
LQ Newbie
 
Registered: Aug 2009
Location: Denmark
Posts: 4

Original Poster
Rep: Reputation: 0
Sorry i have wrote it like that, I will try to clear it a bit.

The part I need to rewrite is this:

--------------------------------------------
pwgen > /tmp/pass.txt
setpass="`cat /tmp/pass.txt`"
pass=$setpass
echo "Adding User $USERNAME to system"
useradd -m -d $HOMEDIR $USERNAME
usermod -s "$SHELL" -p "$setpass" $USERNAME

znc --makepass
--------------------------------------------

First it is generating a random password to use for the user being added
Second it is adding the user, his homedir and the password to connect with ssh
Third it run the znc --makepass command that will ask for a password twice and make a crypted password out of that (look in first post for examble). Its the 2 times it ask for the password I would like to have the variable $pass into those without i have to type them myself.

Hope this clears it a little
 
Old 08-10-2009, 05:02 AM   #4
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,158

Rep: Reputation: 247Reputation: 247Reputation: 247
Hi

You could try to pipe the password into the znc command.

(echo $pass ; echo $pass) | znc --makepass
 
Old 08-10-2009, 06:08 AM   #5
loopstr
LQ Newbie
 
Registered: Aug 2009
Location: Denmark
Posts: 4

Original Poster
Rep: Reputation: 0
Hi Guttorm

Its not working im sorry to say.

Im beginning to think the other solution would be better. Its to find a way to make that md5#9463a1389d1454b139b610f032ab4c74#WemSsk6USR0+51V-ZKXh# string
 
Old 08-10-2009, 09:37 AM   #6
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,158

Rep: Reputation: 247Reputation: 247Reputation: 247
Hi

I just tried to install znc, and it looks like it does some trickery so you cannot pipe input into it. You could try to use the "expect" utility.

But I also tried the command, and I don't get the same result as you. I use Ubuntu so we probably have some different versions.

Code:
znc --makepass
[ ?? ] Enter Password:
[ ?? ] Confirm Password:
[ ** ] Use this in the <User> section of your config:
[ ** ] Pass = 098f6bcd4621d373cade4e832627b4f6 -
The password I typed was "test" without the quotes. The hash is md5, so it's easy to get it using the md5sum command.

Code:
echo -n test |md5sum
098f6bcd4621d373cade4e832627b4f6  -
 
Old 08-10-2009, 02:10 PM   #7
loopstr
LQ Newbie
 
Registered: Aug 2009
Location: Denmark
Posts: 4

Original Poster
Rep: Reputation: 0
Thats wierd, I get that really long md5 and cant reproduce it with the md5sum command.

But its different version I guess, the password you generate with ubuntu is not secure acording to this: http://passcracking.com/index.php

There is 2 files shipped with the source package called MD5.cpp and MD5.h and its proberly those who control it all, so the hash string is longer (more bits) I wonder if there is any way to use those to create is outside of the znc program.

Any advice would be appreciate
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
User input into Bash scripts and checking validity of user input?? helptonewbie Programming 8 07-07-2008 07:40 PM
calling user input in bash script dbmacartney Linux - General 3 05-19-2008 07:55 AM
mask user input in a bash script PlatinumRik Linux - Software 1 06-15-2004 11:06 AM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 01:20 AM
User input using a BASH script... causticmtl Programming 5 07-13-2003 10:59 PM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration