LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 12-23-2011, 03:04 PM   #1
Jean-Luc Besson
LQ Newbie
 
Registered: Jun 2009
Distribution: Ubuntu, Arch
Posts: 17

Rep: Reputation: 1
Question Hashing multiple user:password combinations (sha)


Hi Everybody,

I just received a spreadsheet containing quite a few user names and (unhashed) passwords. I need to salt these combinations, preferably with SHA. How would I approach such a task, given that I can't script?

What I wanna do with it:
I need to add those salted combinations (user:hashedpw) to a .htgroup file on a web server.

Can anyone help me out? Point me to a script or anything? I really need some help.

Thanks a billion.
Jean-Luc
 
Old 12-24-2011, 09:12 AM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 2,393

Rep: Reputation: 812Reputation: 812Reputation: 812Reputation: 812Reputation: 812Reputation: 812Reputation: 812
If you are using apache you should use htpasswd.

If the spread sheet is just a .csv (comma separated value) file it could be as simple as
Code:
tr '\n' , < users.csv | xargs -n2 -d, htpasswd -b -s .htgroup
Watch out for extra columns, or special characters though.
 
1 members found this post helpful.
Old 12-24-2011, 10:04 AM   #3
Jean-Luc Besson
LQ Newbie
 
Registered: Jun 2009
Distribution: Ubuntu, Arch
Posts: 17

Original Poster
Rep: Reputation: 1
Hi,

thank you for that tip. Just tried it. Converted the contents of the spreadsheet to a csv list containing the "user,password" combinations. Each in it's own line. The spreadsheet is located in my home directory.

If I try your code, I get the following:

Quote:
~$ tr '\n' , < users.csv | xargs -n2 -d, htpasswd -b -s .htgroup
xargs: htpasswd: No such file or directory
Creating a htpasswd file or directory, does not make any difference. What am I doing wrong?

Thank you very much so far for your help.
Jean-Luc.
 
Old 12-24-2011, 10:18 AM   #4
Jean-Luc Besson
LQ Newbie
 
Registered: Jun 2009
Distribution: Ubuntu, Arch
Posts: 17

Original Poster
Rep: Reputation: 1
OK, I'm a few steps further. I had to install htpasswd first. Did that. I also had to add -c to create the htgroup file.

Code:
~$ tr '\n' , < users.csv | xargs -n2 -d, htpasswd -b -s -c .htgroup
all users and names ran through on my terminal....

Code:
...
Adding password for user Zidane
Adding password for user Zorn
Unfortunately the .htgroup file contains only the last user. In this case "Zorn". Does anybody have an idea what I can do to get all users and hashed passwords in that file?
 
Old 12-24-2011, 08:54 PM   #5
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 2,393

Rep: Reputation: 812Reputation: 812Reputation: 812Reputation: 812Reputation: 812Reputation: 812Reputation: 812
Quote:
Originally Posted by Jean-Luc Besson View Post
I also had to add -c to create the htgroup file.
Quote:
Originally Posted by http://httpd.apache.org/docs/2.2/programs/htpasswd.html
htpasswd - Manage user files for basic authentication
...
Options
...
-c
Create the passwdfile. If passwdfile already exists, it is rewritten and truncated.
Passing -c will overwrite the file on every run (it's somewhat unfortunate there isn't an option to only create if doesn't exist...), maybe use touch to create it first:
Code:
touch .htgroup
tr '\n' , < users.csv | xargs -n2 -d, htpasswd -b -s .htgroup
 
1 members found this post helpful.
Old 12-28-2011, 06:28 AM   #6
Jean-Luc Besson
LQ Newbie
 
Registered: Jun 2009
Distribution: Ubuntu, Arch
Posts: 17

Original Poster
Rep: Reputation: 1
I must use my brain more.

I was able to get my task done. Thank you very much for all your help. I really appreciate what you've done.
 
  


Reply

Tags
hash, passwd


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
[SOLVED] SQL query: multiple combinations krilen Programming 5 07-22-2011 12:45 PM
users who have never changed their password from /etc/sha catalint Programming 1 05-18-2011 08:17 AM
linux password hashing indienick Programming 5 05-18-2006 02:12 PM
Hiding smb mount password in fstab? Hashing? humbletech99 Linux - Networking 5 03-25-2006 11:07 AM
Command-line 'adduser': password not hashing Talesin Fedora 0 10-08-2004 08:19 PM


All times are GMT -5. The time now is 12:53 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