- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
是否可以向 .hpasswd 文件中的密码添加盐?我假设不是,因为服务器需要为每个用户提供盐来验证密码,我想不出它是如何获取它们的,但否则如果要获取列表,它就会很容易受到攻击。有解决办法吗?
非常感谢您的帮助,
本
最佳答案
默认情况下,htpasswd 使用标准 crypt函数,因此密码已经加盐 - 请注意,在此示例中,两个用户都具有相同的密码,但哈希值不同:
simon@diablo:~$ htpasswd -b -c htpasswd simon abcdAdding password for user simonsimon@diablo:~$ htpasswd -b htpasswd simon2 abcdAdding password for user simon2simon@diablo:~$ cat htpasswd simon:NWvm/LCCxQ64Esimon2:2I.LBzsRqULN6
(note: the -b
flag is normally discouraged because other users can see your command line arguments and hence the password)
The first two characters of the hash are the salt; passwords are verified by calling crypt()
again. Entering the wrong password produces a string that's unequal to the hashed password:
>>> from crypt import crypt
>>> crypt("wrongpass", "NWvm/LCCxQ64E")
'NWbxQgX1unvso'
>>> crypt("abcd", "NWvm/LCCxQ64E")
'NWvm/LCCxQ64E'
htpasswd -m
使用基于 MD5 的不同算法并使用更长的盐:
simon@diablo:~$ htpasswd -m -b -c htpasswd simon abcdAdding password for user simonsimon@diablo:~$ cat htpasswdsimon:$apr1$mfvnBVmG$iIHIHOaH9vcImG5G.8eVa/
Here, the salt is the 8 characters between the second and third $
.
htpasswd -s
stores a SHA-1 digest with no salt; this appears to be for compatibility with Netscape/LDIF:
simon@diablo:~$ htpasswd -s -b -c htpasswd simon abcdAdding password for user simonsimon@diablo:~$ htpasswd -s -b htpasswd simon2 abcdAdding password for user simon2simon@diablo:~$ cat htpasswd simon:{SHA}gf6L/odXbD7LIkJvjleEc4KRes8=simon2:{SHA}gf6L/odXbD7LIkJvjleEc4KRes8=
These can easily be reversed - convert into a hex digest:
>>> "".join("%02x" % ord(c)
... for c in "gf6L/odXbD7LIkJvjleEc4KRes8=".decode("base64"))
'81fe8bfe87576c3ecb22426f8e57847382917acf'
关于encryption - 向 .htpasswd 添加盐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4175707/
我有一个通过 htpassword 调用运行用户名和密码的脚本: /usr/local/apache2/bin/htpasswd -b $file $user $pass 并将它们添加到文件中。 b
我有一个通过 htpassword 调用运行用户名和密码的脚本: /usr/local/apache2/bin/htpasswd -b $file $user $pass 并将它们添加到文件中。 b
我正在记录在我的开发服务器上完全重新部署的过程。小型员工,使用基本身份验证(当然是通过 SSL)和 htpasswd 文件后端。 按原样传输 .htpasswd 文件是否安全? 操作系统可能会有所不同
我有一个 protected 目录,只有.htpasswd上的用户可以访问,但是有时它要求用户更改密码或用户名,将特定的用户名密码编辑为其自己的用户名 sample users kevien : kk
我有一个特定于语言的子域,它指向与我的站点的根目录相同的目录。我使用 PHP 来检测它并显示语言。 我只想在这个子域上设置一个 htpasswd。请记住,没有特定于该子域的物理目录。因此,该语句将与我
假设站点较小(页面数少于5个),.htaccess和.htpassword的正确用法是什么?我最近观看了a tutorial from Nettuts+给出此示例代码的地方: .htaccess Au
我想知道为什么即使对于相同的用户名和密码,htpasswd每次也会输出一个新的哈希值?我试图找到该问题的答案,但没有。 最佳答案 “ htpasswd”生成的密码使用随机盐,以使其更难猜测。这也意味着
我将我的网站推送到多个服务器,其中我有不同的用户名。我想要一个 .htaccess 文件,无论我在哪个服务器上,它都可以通过密码保护文件。 问题是 AuthUserFile只采用绝对路径,所以如果我有
我的问题很简单。 如何允许用户更改存储在 linux 中某些 htpasswd 文件中的密码而不泄露文件内容或允许用户修改其他密码? 我试图编写一个脚本来使用 ssh 和专门设计的用户来完成这项工作,
我正在尝试从命令行自动创建密码。我已经尝试了以下方法,但它仍然不断要求输入密码。 echo "test101" | htpasswd -c ~/temp/password admin 如何在不输入密码
是否有一种编程方式来构建 htpasswd 文件,而不依赖于操作系统特定的函数(即 exec()、passthru()) ? 最佳答案 .httpasswd 文件只是具有特定格式的文本文件,具体格式取
我想通过 .htpasswd 保护网络文件夹。 但是,由于 .htaccess 文件受版本控制,我不想弄乱它。 相反,我希望配置在 /etc/apache2/sites-enabled/mysite
是否可以密码保护虚拟目录(例如 wordpress 类别): /c/sofas/ 它看起来像 可以在 httpd_config 中工作,但不能在 .htaccess 中使用 是否可以?可能在某处使用
我有一个带有 htaccess 和 htpasswd 的密码保护目录。 我的 .htpasswd文件看起来像这样 user1:passwordstring user2:passwordstring u
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 9 年前。 Improve this
我通过 htaccess 和 htpasswd 保护了几个页面。到目前为止网站运行良好,但最近几天,我们遇到了一些问题,我不排除这部分代码。 我的 htaccess: AuthName "Name
是否可以向 .hpasswd 文件中的密码添加盐?我假设不是,因为服务器需要为每个用户提供盐来验证密码,我想不出它是如何获取它们的,但否则如果要获取列表,它就会很容易受到攻击。有解决办法吗? 非常感谢
我需要使用用户名/密码对网站进行密码保护,但需要保持“/assets”文件夹可访问,因为图像/css 等文件被嵌入到其他网站上。 我有这个保护: Order Allow,Deny AuthType B
我有一个带有 htaccess 和 htpasswd 的受密码保护的目录。 htaccess 看起来像这样 AuthUserFile /usr/local/you/safedir/.htpasswd
我正在使用 .htpasswd 来密码保护我的服务器上的某些目录。但是,我注意到每次执行此操作 sudo htpasswd -c/etc/apache2/.htpasswd newuser 时,我当前
我是一名优秀的程序员,十分优秀!