LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-06-2010, 10:57 PM   #1
chobong
Member
 
Registered: Jan 2010
Posts: 90

Rep: Reputation: 15
How to sync md5 password between php and htpasswd


Dear All,

I have built a subversion server (1.6.12 version) on Centos 5.4.
I created a database for the server for authentication user via database MySQL with mod_auth_mysql, but this make my subversion server is so slow when make a commit.

I think authentication through a file is fast , but I wish to connect the password in database (the password is created by PHP) to file.
I used a file like this
user:xxx
xxx is the password which is got from database. But it's not ok.

If anyone knows, please let me know how should I do that.
Thanks so much.

Last edited by chobong; 07-06-2010 at 10:59 PM.
 
Old 07-15-2010, 03:51 PM   #2
uko
LQ Newbie
 
Registered: Aug 2008
Posts: 2

Rep: Reputation: 1
You obviously want to create a password protected site and use php scripts to administrate users?

typically a password file for apache is created using htpasswd (for apache 1.x) or htpasswd2 for apache 2.

To add a new user you may execute htpasswd from your php session:
<?php
define("HT_PASSWD_ENCRYPT", "m");
// HT_PASSWD_ENCRYPT may be one of:
// d use crypt() encryption, not Win32
// m use MD5 encryption
// s use SHA encryption

function newUser($un, $pw)
{
$cmd = get_htpasswd() . ' -b' . HT_PASSWD_ENCRYPT . ' ' . escapeshellarg($pwFile) . ' ' . escapeshellarg($un) . ' ' . escapeshellarg($pw);
system($cmd, $rc);
}

?>

You may basically do the same thing if you want to change the password.

Hope this helps.
 
  


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 Password -vs- HTPASSWD Password? carlosinfl Linux - Security 1 10-14-2009 10:26 AM
[SOLVED] PHP code nothing happens when htpasswd issued qwertyjjj Linux - Software 11 08-16-2009 11:01 AM
Want to script a way to sync htpasswd with passwd and shadow happyjack Linux - Server 1 11-28-2007 10:40 AM
htpasswd password file fw12 Linux - Newbie 5 07-16-2006 02:26 PM
PHP generate htpasswd newuser455 Programming 2 06-12-2006 11:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

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