使用htpasswd.pl脚本远程管理apache密码文件

HTAdmin:HTAdmin 的古老代码,一个用于管理 Apache .htpasswd 文件的简单 PHP 工具 HT管理员 警告; 这个项目几乎不被弃用,不要在生产中使用它。 HTAdmin 是用于管理 Apache .htpasswd 文件的基本且简单的 PHP 工具。 开发从 2000 年(PHP 4 首次发布时)开始,并在 2005 年(PHP 5 之前)停止。 要求 Linux/Unix/BSD、Windows 或 Mac OS X 阿帕奇网络服务器 PHP 安装 编辑 config.inc.php 文件中的以下几行: $cfgUseAuth = true; $cfgSuperUser = 'admin'; $cfgSuperPass = 'password'; $cfgHTPasswd[0][N] = '/htdocs/example/.htpasswd'; // First file's full path and name 立即下载
   在搭建trac/svn系统时,一般都会采用apache的.htacces 认证方法 但trac本身并不提供修改密码的功能,修改密码只能通过htpasswd/htpasswd2命令来进行,这的确是一件相当不make sense的事。
   其实,利用一个免费的perl脚本可以方便的通过http方式修改apache的认证文件。
  文件名:htpasswd.pl,获取地址http://home.xnet.com/~efflandt/pub/htpasswd.pl
   该脚本可以通过web浏览器从你的htpasswd文件直接增加或者删除用户,管理者密码是经过加密的。该脚本本身并不保护一个目录,也不创建一个口令保护功能。它仅用来帮助你管理你的口令文件。这就是说在你的服务器上事先应有口令文件时,该脚本方可发挥作用。

   安装&配置

   step1.拷贝htpasswd.pl至cgi-bin目录
   suse对应/srv/www/cgi-bin
   fedora对应/var/www/cgi-bin
   step2.改名
   把htpasswd.pl改名为htpasswd.cgi
   step3.
用文本编辑器打开配置脚本(cfg.pl)
    编辑如下变量:
    #!/usr/local/bin/perl 修改为 #!/bin/perl
    配置要修改的apache认证文件,找到以下几行
   
# Password file with full system path (where not accessible by URL).
    $file = '/full_path_to/.htpasswd';
修改为 $file='/etc/svn-auth-file'#假设你的验证文件是/etc/svn-auth-file  
   step4 chmod 755 htpasswd.cgi

   不出意外的话,访问http://localhost/cgi-bin/htpasswd.cgi即可出现密码修改页面
 有关密码文件创建,请参见 http://blog.youkuaiyun.com/forlinux/archive/2006/06/11/787703.aspx
 
  -----htpasswd.pl-------
  1. #! /usr/local/bin/perl -T
  2. # htpasswd.cgi by David Efflandt (efflandt@xnet.com) 8/97
  3. # Last update 10/4/99
  4. #
  5. # Update password file from the web for use with user authentication.
  6. # Stores each line in the format: username:crypted_password
  7. #
  8. # Built-in form is provided if you GET the script.
  9. # Form is processed if you POST to this script.
  10. #
  11. # If you want your passwords to be secure, it is best to run this
  12. # suid as you (chmod 4705 htpasswd.cgi) which may require C wrapper.
  13. # Also keep this script in a directory that requires user authentication
  14. # unless you allow new users to set their own password (see $allow_new).
  15. #
  16. # If not running suid you should touch the password file first and
  17. # chmod 606 (or whatever is req'd to access it as you and webserver).
  18. #
  19. # To add or remove users by an administrator, create a user called 'admin'
  20. # with a password.  Enter username you want to add or remove with admin
  21. # password as "Current Password" (plus new passwords for new users).
  22. #
  23. # Anyone may remove their own name from the password file if they supply
  24. # their correct password.
  25. ### Variables
  26. # Password file with full system path (where not accessible by URL).
  27. $file = '/full_path_to/.htpasswd';
  28. # Allow anyone to add new users (1 = yes, 0 = no)
  29. $allow_new = 0;
  30. # Set untainted path for suid scripts
  31. $ENV{PATH} = '/bin:/usr/bin:/usr/local/bin';
  32. $ENV{IFS} = "" if $ENV{IFS} ne "";
  33. ### End of Variables
  34. # Create form and exit on GET
  35. &make_form unless ($ENV{'REQUEST_METHOD'} eq "POST");
  36. # Get POST input
  37. read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
  38. # Split the name-value pairs
  39. @pairs = split(/&/, $buffer);
  40. foreach $pair (@pairs)
  41. {
  42.   ($name, $value) = split(/=/, $pair);
  43.   $value =~ tr/+/ /;
  44.   $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  45.   $name =~ tr/+/ /;
  46.   $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  47.   $FORM{$name} = $value;
  48. }
  49. if ($FORM{user}) {
  50.   $user = $FORM{user};
  51. } else {
  52.   &error("Error", "Username missing from form.");
  53. }
  54. $pwd = $FORM{old};
  55. $command = $FORM{command};
  56. unless (($command eq 'remove')
  57.     ||($FORM{new} && $FORM{new} eq $FORM{new2})) {
  58.   &error("Password Mismatch", "New password mismatch or missing.");
  59. }
  60. # Get existing passwords
  61. if (-e $file) {
  62.   open (IN, $file) or &error("Error", "Can't open password file: $!");
  63.   flock(IN,2);
  64.   seek(IN,0,0);
  65.   while (<IN>) {
  66.     chomp;
  67.     ($name, $value, $tail) = split(/:/, $_, 3);
  68.     $hash{$name} = $value;
  69.     $tail{$name} = $tail;   # maintain any additional fields
  70.   }
  71.   close IN;
  72. }
  73. # Salt for crypt
  74. @range = ('0'..'9','a'..'z','A'..'Z','.','/');
  75. srand ( time() ^ ($$ + ($$ << 15)) );
  76. $salt = $range[rand(int($#range)+1)] . $range[rand(int($#range)+1)];
  77. # Check for valid password or existing user
  78. $pass = $hash{$user} if $hash{$user};
  79. $cpwd = crypt($pwd, $pass);
  80. $admin = $hash{admin} && crypt($pwd, $hash{admin}) eq $hash{admin};
  81. if (($command ne 'new') && ($admin || $pass && $cpwd eq $pass)) {
  82.   if ($command eq 'remove') {
  83.     delete($hash{$user}); delete($tail{$user});
  84.     $msg = "User <B>$user</B> was removed from password file.";
  85.   } elsif (!$pass) {
  86.     $msg = "WARNING! 'Change Password' checked for non-existing user?/n"
  87.     . "<P>Assigning password for new user <B>$user</B> anyway./n"
  88.     . "<P>If this was an error, go back and 'Remove User'";
  89.   } else {
  90.     $msg = "Password has been updated for $user.";
  91.   }
  92. } elsif ($FORM{command} eq 'new') {
  93.   if ($pass) {
  94.     &error("Sorry", "User <B>$user</B> is already assigned.");
  95.   }elsif ($allow_new || $admin) {
  96.     $msg = "Password has been assigned for new user $user.";
  97.   } else {
  98.     &begin_html("Sorry, New User");
  99.     print "Contact file owner for password you can change later.";
  100.     &end_html;
  101.     exit;
  102.   }
  103. } else {
  104.   &error("Password Error", 
  105.     "Invalid user or password or forgot to check 'New User'.");
  106. }
  107. # Assign new password to user and write to file
  108. $hash{$user} = crypt($FORM{new}, $salt) if $command ne 'remove';
  109. if (open(OUT, ">$file")) {
  110.   flock(OUT,2);
  111.   seek(OUT,0,0);
  112.   foreach $name (sort keys %hash) {
  113.     print OUT "$name:$hash{$name}";
  114.     print OUT ":$tail{$name}" if $tail{$name};
  115.     print OUT "/n";
  116.   }
  117. } else {
  118.   &error("Error","Can't update password file: $!");
  119. }
  120. # Print Return HTML
  121. &begin_html("Thank You");
  122. print "$msg/n";
  123. &end_html;
  124. ### Subroutines
  125. #subroutine begin_html(title)
  126. sub begin_html {
  127.   local ($title) = @_;
  128.   print "Content-type: text/html/n/n";
  129.   print "<html><head><title>$title</title></head><body>/n";
  130.   print "<center><h1>$title</h1></center>/n<hr><p>/n";
  131. }
  132. #subroutine end_html
  133. sub end_html {
  134. # Add footer links here
  135.   print "<P></body></html>/n";
  136. }
  137. #subroutine make_form
  138. sub make_form {
  139.   &begin_html("Change or Add Password");
  140. print <<NEW_FORM;
  141. Use this form to change your password for access to restricted
  142. directories here.  New users will be informed if password was assigned or
  143. if they need to contact the owner of these pages.
  144. <FORM METHOD="POST" ACTION="$ENV{SCRIPT_NAME}">
  145. <DL>
  146. <DT> E-mail Address (or username on this system): 
  147.  <DD><INPUT NAME="user">
  148. <DT> Current Password (required unless new user): 
  149.  <DD><INPUT TYPE=PASSWORD NAME="old">
  150. <DT> New Password: 
  151.  <DD><INPUT TYPE=PASSWORD NAME="new">
  152. <DT> Confirm New Password: 
  153.  <DD><INPUT TYPE=PASSWORD NAME="new2">
  154. <DT>Request:
  155.  <DD>
  156.   <INPUT TYPE="radio" NAME="command" VALUE="change" CHECKED> Change Password
  157.  <DD>
  158.   <INPUT TYPE="radio" NAME="command" VALUE="new"> New User
  159.  <DD>
  160.   <INPUT TYPE="radio" NAME="command" VALUE="remove"> Remove User
  161. </DL>
  162. <P><INPUT TYPE="submit" VALUE=" Submit Request ">
  163. </FORM>
  164. NEW_FORM
  165.   &end_html;
  166.   exit;
  167. }
  168. sub error {
  169.   local($title,$msg) = @_;
  170.   &begin_html($title);
  171.   print "<P>$msg/n";
  172.   print "<P>Please check your name and re-enter passwords./n";
  173.   &end_html;
  174.   exit;
  175. }

 
htpasswd:用于HTTP基本身份验证密码文件实用程序的Node.js程序包 htpasswd 用于管理HTTP基本身份验证密码文件的CLI工具。 基本上,这是Apache 实用程序的Node.js实现。 安装 通过git(或下载的tarball): $ git clone git://github.com/http-auth/htpasswd.git 通过 : $ npm install -g htpasswd 用法 $ htpasswd [-cimBpsDv] [ -C cost ] passwordfile username $ htpasswd -b[cmBpsDv] [ -C cost ] passwordfile username password $ htpasswd -n[imBps] [ -C cost ] username $ htpasswd -nb[mBps] [ -C cost ] username password 选件 -b从命令行使用密码,而不是提示输入密码。 应谨慎使用此选项,因为密码在命令行上清晰可见。 有关脚本的使用,请参见-i选项。 -i从标准输入读取密码而不进行验证(用于脚本)。 -c创建一个新文件。 - 立即下载

相关推荐

rpm包安装htpasswd所需包

rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包安装htpasswd所需包rpm包

linux命令:httpd 安装配置及网页虚拟主机 elinks htpasswd

LAMP:L=linux A=apache网页服务器 M=mysql数据库服务器 P=php应用服务器httpd: 事先创建进程,按需维持适当的进程,模板化设计,核心比较小,各种功能都模块添加,支持运行配置,支持单独编译模块。httpd -t用于检测httpd.conf主配置文档是否存在语法错误[root@johntest conf]# httpd -tS...

weixin_34380948的博客 258

超简单的HTPASSWD账号管理

以一个PHP文件实现HTACCESS BasicAuth 的账号密码管理 可以管理MD5 SHA UNIX-CRYPT的账户密码 不是简单的php exec()调用,因此适合safe_mode的环境 此程序假设了用户已BasicAuth(appache)登录成功。 程序包含了密码强度检查(JQUERY) 注释很明白,适用性强。 (欢迎转载,但鄙视改作者信息的)

htpasswd.cgi 网页远程修改gerrit HTTP认证的密码文件

在搭建gerrit系统时,一般都会采用apache的.htacces 认证方法 但trac本身并不提供修改密码的功能,修改密码只能通过htpasswd/htpasswd2命令来进行,这的确是一件相当不make sense的事。 其实,利用一个免费的perl脚本可以方便的通过http方式修改apache的认证文件。   文件名:htpasswd.pl,获取地址http://home.xnet.c

dongwuming的专栏 4845

Circos图审美拯救计划:用TBtools复刻Nature级共线性分析图谱

本文针对Circos图在共线性分析中的审美提升问题,提供了一套基于TBtools的完整优化方案。通过构建和谐的色彩体系、精细控制信息层布局以及模仿顶刊构图逻辑,详细讲解了如何从配色、透明度、标签显示到高级参数设置,将默认图表升级为具有高级学术美感的Nature级图谱,助力研究者提升论文图表质量。

cherry的博客 911

【无标题】

可以看到这是一个带过滤的rce,并且还需要绕过空格,通过·查询资料得到了${IFS},$IFS$9,<,$IFS。然后f,l,a,g都被过滤了,可以用中括号[]来进行正则匹配,把GET传的参数改为?cmd=uniq /[e-h][k-n][^-b][e-h],就得到了flag。cmd={%0A"cmd":"/bin/cat /home/rceservice/flag"%0A}可以看到l被过滤了ls用不了了可以用dir用GET传参cmd=dir /,POST传参shell=system。

2501_94507425的博客 303

Windows下安装Apache搭建文件服务下载

进入Apache官网 官网地址:http://httpd.apache.org/ 点击Download 选择Windows版下载,点击链接 下载安装包 解压压缩包到指定的文件夹 修改配置文件 打开D:\Apache-httpd\Apache24\conf\httpd.conf文件 ① 修改Apache安装目录,最后结尾处不能带“/”或“\”,如下图所示(其中“$...

storm_fury 3203

山东大学软件工程应用与实践——GMSSL开源库(六)——SM9密钥交换协议

2021SC@SDUSC 文章目录基本概念符号及辅助算法SM9密钥交换协议 基本概念 1976年,Diffie和Hellman在其题为《密码学的新方向》的论文中首次给出了公钥密码学的定义,并提出了Diffie-Hellman密钥交换算法。该算法解决了对称密码体制中的密钥分发问题,使得通信双方可以通过公开信道安全地交换共享密钥。 使用SM9通信的双方通过对方的标识和自身的私钥,经过两次或者可选的三次信息传递过程,计算获取一个由双方共同决定的共享秘密密钥。该密钥可以作为对称密码算法的会话密钥,其中可选步骤用来实

m0_51588039的博客 1988

【Nginx】Nginx 鉴权 (htpasswd) + Nginx 文件下载配置

本文介绍了Nginx 鉴权 (htpasswd) + Nginx 文件下载配置。

MichelleChung的星球 4475

deepin启动异常处理

修复的命令在执行时会输出大量的修复信息,正常情况下修复完之后输入exit命令回车后,即可正常启动系统。

whxxiang的博客 4369

【ArcGIS风暴】Win10操作系统ArcGIS许可License无法启动的解决方法汇总(绝对成功!)

文章目录1. 关闭Windows Defender2. 关闭系统防火墙3. 删除迈克菲(McAfee)杀毒软件4. 在系统服务中启动 在安装ArcGIS软件时,最重要的一步是许可服务的正常启动,通常,由于各种各样的原因,ArcGIS许可管理器License Manager十有八九会无法启动,点N多次都没反应,如果许可服务不能如愿启动的话,即使Desktop安装成功,也是无法打开的。本文汇总了Win10操作系统之上ArcGIS安装过程中可能会导致服务无法启动的原因及解决办法。 ArcGIS安装参考教程:

智慧空间实验室 2万+

htpasswd linux,Centos安装htpasswd_Nginx中使用htpasswd

htpasswd 是开源 http 服务器 apache httpd 的一个命令工具,用于生成 http 基本认证的密码文件。接下来吾爱编程为大家介绍一下Centos安装htpasswd,有需要的小伙伴可以参考一下:1、安装(1)、ubuntu安装:sudoapt-getinstallapache2-utils(2)、centos安装:yum-yinstallhttpd2、语法htpa...

weixin_35002851的博客 1457

杰理JL701N内置flash录音配置教程

本文详细介绍了内置Flash录音功能的配置方法。主要内容包括:1) 基础模式配置(开启音乐/录音模式、Flash录音宏定义);2) 录音参数设置(格式基准值、存储区域定义、容量配置);3) MP3编码特殊处理;4) 下载时的Flash格式化操作;5) 录音开关和播放接口的使用说明。配置过程涉及多个关键文件的修改,并强调存储容量的精确分配。

qq_42014563的博客 597

『Nginx安全访问控制』利用Nginx实现账号密码认证登录的最佳实践

📣读完这篇文章里你能收获到:如何创建用户账号和密码文件,并生成加密密码,配置Nginx的认证模块,实现基于账号密码的登录验证

老陈聊架构 4707

基于STM32的太阳能充电宝设计_资料编号31

系统硬件包括主控 STM32F103C8T6、0.96 OLED 显示屏、蜂鸣器、电源自锁开关、温度传感器 DS18B20、继电器、5 V DC 升压模块 、TB4056、18650锂电池、9 V太阳能板、稳压降压 5 V三极管。电源供应:锂电池为系统供电,9 伏太阳能板经 5 伏降压稳压三极管降压为 5 伏后传送到 TP4056,TP4056 为锂电池供电,因锂电池电压 3.7 伏,通过 5 伏 DC 升压模块升压到 5 伏为整个系统提供 5 伏电压。

嵌入式阿齐Archie 1万+

第6章: MMU Notifier在KVM虚拟化中的应用

本文分析了KVM如何利用MMU Notifier机制维护客户机与宿主机地址映射一致性。KVM采用三层地址空间转换架构(GVA→GPA→HPA),通过硬件辅助虚拟化(EPT/NPT)实现高效转换。重点探讨了KVM MMU Notifier回调实现,包括invalidate_range_start/end等核心函数,以及HVA范围处理流程。当宿主机内存变化时,KVM通过注册的notifier回调及时更新映射关系,确保虚拟化环境的内存一致性。文章详细解析了相关数据结构和关键代码实现,揭示了KVM内存管理的核心机制

图形/计算GPU的驱动与虚拟化技术分享园地 2318

linux系统中安装htpasswd

htpasswd是Apache附带的程序, htpasswd生成包含用户名和密码的文本文件, 每行内容格式为“用户名:密码”, 用于用户文件的基本身份认证。 当用户浏览某些网页的时候, 浏览器会提示输入用户名和密码, 比如awstats的日志报表, 你肯定不希望别人也能访问, 因此就需要对这些报表网页的访问增加身份验证。 如果你的web服务器是apache的话, 那么应该会自带htpasswd程序的, 不过我用的是nginx作反向代理, 所以就需要安装一下了 输入htpasswd, 系统会提示在哪个包中可以

qq_40021015的博客 5661

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

htpasswd命令详解

1、htpasswd介绍安装 Nginx的源码提供了ngx_http_auth_basic_module这个模块,它可以来解决web访问认证的问题。这个模块是默认就编译进nginx的,可以直接拿来使用。 ngx_http_auth_basic_module它提供了最基本的http认证,这是http协议支持的,它会弹出一个框让你输入用户名和密码,只有用户名和密码输入正确了才能访问,这样就能保证自己的web不被任何人所访问。 ngx_http_auth_basic_module是使用文件作为存储介质的,用户名

ben_na_的博客 8412

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

ubuntu nginx配置密码访问并下载

【代码】ubuntu nginx配置密码访问并下载。

sun007700的专栏 564

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Linux 中httpd基于文件的用户的访问控制和CGI

基于用户访问控制(这里控制的是整个页面控制) 用户认证类型: 基本认证:Basic 摘要认证:digest,是否明文还是密文的控制。 虚拟用户:仅用于访问某服务和获取资源的凭证: 用户帐号密码存放位置:.htpasswd 这个文件用户名是明文的,密码是加...

weixin_33691817的博客 218

蓝易云:Nginx使用htpasswd配置访问密码教程

网站时,将会弹出一个认证对话框,要求用户输入之前设置的用户名和密码。命令创建密码文件,并在其中添加用户及其密码。密码文件通常存储在服务器的安全位置,确保不可公开访问。是Apache工具包中的一部分,用于管理基本的HTTP身份验证。希望这个回答对你有所帮助,如果你需要进一步的解释或有其他问题,请随时提问。是你要创建的用户名。运行此命令后,你将会被要求输入密码并确认密码。当你想要在Nginx上配置访问密码时,可以使用。替换为你在步骤2中创建的密码文件的实际路径。,根据你的配置文件位置进行调整。

高性价比服务器就选:蓝易云 1099

centos下安装htpasswd命令(httpd),常用于nginx的密码设置

安装: yum-yinstallhttpd htpasswd命令的参数说明: -c创建passwdfile.如果passwdfile已经存在,那么它会重新写入并删去原有内容. -n不更新passwordfile,只将加密后的用户名密码显示在屏幕上; -m默认采用MD5算法对密码进行加密 -d采用CRYPT算法对密码进行加密 -p不对密码进行进行加密,即使用普通文本格式...

西门大盗 捉虫专家 6949

安装htpasswd命令

阿白, 1740

Linux命令-htpasswd命令(创建和管理用于 HTTP 基本认证(Basic Authentication)的密码文件)

是 Apache HTTP 服务器的一个实用工具,主要用于创建和管理用于 HTTP 基本认证(Basic Authentication)的密码文件。它通过加密的方式存储用户名和密码,从而保护 Web 目录的访问安全。除了 Apache,它也可用于配置 Nginx 等服务器的基本认证。直接使用相同的用户名再次运行命令,即可更新密码。这实际上是先删除旧用户记录再添加新记录的过程。选项可以将加密后的结果输出到屏幕,方便直接查看或用于其他用途。选项,否则会覆盖原有文件。,添加第二个及后续用户时,

RisunJan的博客 814

使用Nagios打造专业的业务状态监控

通常我们会在项目所在的机房部署一套监控系统来监控我们服务器和MySQL之类的公共服务,制定报警策略,在出现异常情况的时候邮件或短信提醒我们及时处理。 此类监控主要的关注点有两个: 资源的占用情况,例如负载高低、内存大小、磁盘空间等 服务的状态监控,例如Nginx状态、Mysql主从状态等 同时也会存在以下两个主要问题: 缺少业务状态的监控,不能很直观的知道业务当前的状态,可能服务器、服务都正常但业...

Tybyqi的博客 761
上一篇: 解决rails 执行 rake db:migrate时Error in my_thread_global_end(): 1 threads didn't exit错误
下一篇: Data-Driven Unit Test with Excel 2007要点
forlinux
博客等级 码龄21年 53粉丝 95原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值