简体   繁体   English

如何使用 php 生成.htpasswd 密钥,我可以将其插入到我的 ubuntu 服务器上的 my.htpasswd 文件中?

[英]How to generate .htpasswd keys with php that I could insert into my .htpasswd file on my ubuntu server?

Its quite honestly hard to understand.老实说,这很难理解。

I have an ubuntu server with my local webserver which Im "securing" with .htaccess and.htpasswd.我有一个 ubuntu 服务器和我的本地网络服务器,我用 .htaccess 和.htpasswd “保护”。

I know that I can just generate it on the mashine itself in bash.我知道我可以在 bash 的机器上生成它。 But for *hits and giggles I want to try to make a simple webpage that I could manage htpasswd file and create users from the browser itself.但是对于*点击和咯咯笑,我想尝试制作一个简单的网页,我可以管理 htpasswd 文件并从浏览器本身创建用户。

I already tried to $str = md5(_Post("pasw")) But I guess these keys are different.我已经尝试过$str = md5(_Post("pasw"))但我猜这些键是不同的。 Maybe could someone help me understand how these hashes are created so that I could make this work hehe.也许有人可以帮助我了解这些哈希是如何创建的,以便我可以完成这项工作,呵呵。

Short ver: How to generate.htpasswd key that I could insert into.htpasswd file in my server so that it would work.简短版本:如何生成 .htpasswd 密钥,我可以将其插入到服务器中的 .htpasswd 文件中,以便它可以工作。

Thank you!谢谢!

(1) sudo nano /etc/apache2/sites-available/000-default.conf (1) sudo nano /etc/apache2/sites-available/000-default.conf

<Directory /usr/share/phpmyadmin>
    AuthType Basic
    AuthName "Restricted Content"
    AuthUserFile /etc/phpmyadmin/.htpasswd
    Require valid-user
</Directory>

(2) sudo htpasswd -c /etc/phpmyadmin/.htpasswd nageen (2) sudo htpasswd -c /etc/phpmyadmin/.htpasswd nageen

for new user: sudo htpasswd /etc/phpmyadmin/.htpasswd localuser对于新用户:sudo htpasswd /etc/phpmyadmin/.htpasswd localuser

asking for add password, add password for user要求添加密码,为用户添加密码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM