htpasswd to mysql table

Can't seem to find this anywhere on the net so time to ask.

How can one take the contents of an htpasswd file and convert it to username/password in a mysql table.
projectsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gheistCommented:
Do you want to use that for authentication against MySQL, or just store file data in a table with two columns?
0
projectsAuthor Commented:
Right, just the two columns, username and password, so I can use apache/mysql auth instead of htpasswd file.
0
gheistCommented:
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

projectsAuthor Commented:
Sorry, I've no idea what the link information means. I know it's to load a file but can you give me an example instead of a link. I searched and tried various things but I'm not a programmer so need more detail.

Thanks.
0
projectsAuthor Commented:
My htpasswd file is pretty small so I could replicate it by hand but I can't find any info on how to create encrypted username/passwords to be stored in mysql. Seems I would need a bash or php script or something to do this.

What I have found so far simply create non encrypted accounts into the mysql table using normal mysql commands. I'd like those to be encrypted in the db along with some plain text ones.
0
gheistCommented:
Do you have httpasswd with plain passwords like netware?
0
projectsAuthor Commented:
Netware? I've not heard that term since the 80's :).

Anyhow, I've re-created all of my users/passwords in a mysql table so now I just need to figure out the stupid changes with centos7 to get this working since mod auth mysql is now deprecated.
0
gheistCommented:
To encrypt salted passwords
openssl passwd -help

-1 -5 -6 are nearly universally supported.
0
projectsAuthor Commented:
Basically, this question is already answered at this point. The question was how to import htpasswd file into a mysql table so I could start using apache mysql auth.

The answer was that I had to re-create all of the accounts manually since I could not find a way of converting/importing the existing htpasswd file into the new mysql table.

My next problem (question?) however will be that of modifying apache to use the new table instead of the .htpasswd file. So far, that seems to be a confusing topic to many because some mods have been deprecated, etc.
0
gheistCommented:
1)

awk -F: '{print $1":" `echo $2 | openssl passwd -1`}' <oldfile > saltfile

2)

Mysql> LOAD DATA FIELDS TERMINATED BY ':' user,password
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gheistCommented:
I think I left unnecessary space before echo - check the file, there should be no space after colon.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.