使用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.csdn.net/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的专栏 4847

U8备份提示“远程组件初始化失败”

问题现象: SQL出现问题后重装,U8没有重装,之后直接附加数据库,U8可以正常登陆,但是在备份的时候提示远程组件初始化失败。 问题原因: 因为重装了SQL,没有进行U8数据源初始化,导致Master库中丢失了存储过程储 解决办法:在Master库重建存储过程 USE [master] GO SET ANSI_NULLS OFF GO SET QUOTED_IDENTIFIER OFF GO CREATE PROCEDURE [dbo].[U8FileServerExtendProc] @cmdLi.

SamYux 2479

第四章 自定义组件、动画

第三章 自定义组件、动画 (一)自定义View 1.1) onMeasure:对当前View的尺寸进行测量 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) widthMeasureSpec和heightMeasureSpec包含测量模式和尺寸大小 int widthMode = MeasureSpec....

Stay Hungry Stay Foolish 求知若饥 虚心若愚 8137

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

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

storm_fury 3203

SwinIR实战:从环境搭建到模型训练的全流程解析

本文提供了SwinIR超分辨率模型从零开始的全流程实战指南。详细解析了基于PyTorch和Anaconda的环境搭建、数据准备与配置文件修改、训练启动与常见错误排查(如张量尺寸不匹配),以及模型评估方法,帮助读者高效部署并训练SwinIR模型。

weixin_28224217的博客 326

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

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

MichelleChung的星球 4475

uni-app - 将 base64 图片编码转为 Blob 本地文件路径(把base64类型的图片,转换成blob二进制文件流)适用于 uni-app / vue.js / JavaScript

uni-app/vue.js/JavaScript将base64转Blob,uniappapp端如何将图片的base64编码转换成File对象或Blob,uni-app/vue.js/JavaScript中拿到base64转blob对象,uniapp图片base64格式转blob格式方法,uniapp上传图片压缩转base64码与base64转图片路径,Base64/Blob/File图片文件转换,url、base64、blob相互转换方法,读取本地文件为Base64并转成B

🏆 前端领域优质创作者 1万+

Mac 下 OpenClaw 安装全记录:从零到一的保姆级图文教程

本文主要介绍了Mac 下 OpenClaw 安装全记录:从零到一的保姆级图文教程,希望能对学习使用OpenClaw 的同学们有所帮助。 文章目录 1. 背景 2. 安装教程 2.1 安装OpenClaw 2.2 配置模型 2.3 对话 3. 后续使用步骤 4. 关闭程序

weixin_43178406的博客 11万+

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的博客 1459

使用Simulink对液流电池在微电网中的动态响应进行建模与仿真

本文介绍了使用Simulink对液流电池在微电网中的动态响应进行建模与仿真的方法。通过搭建包含液流电池、双向DC-DC变换器、分布式能源和负载的微电网模型,并设计基于SOC的控制器,详细说明了从模型创建到仿真运行的完整流程。重点分析了液流电池在不同负载条件下的动态特性,评估了系统响应速度、充放电效率和稳定性等性能指标。该仿真方法为验证液流电池在微电网中的应用提供有效工具,有助于优化参数设计和提升系统可靠性。

amy_mhd的博客 142

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

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

老陈聊架构 4711

创龙 瑞芯微 RK3588 国产2.4GHz八核 工业开发板—ISP图像处理开发案例

创龙科技研发的 TL3588-EVM 评估板具备强大视频处理能力,可满足多场景视频开发需求。为助力开发者快速上手,本文整理 7 个实用视频开发案例,涵盖从采集到显示的全流程,详细说明各案例的硬件连接、参数配置与代码解析,帮助开发者高效实现评估板视频相关功能开发与调试。

创龙,嵌入式一体化解决方案商 222

Android SELinux——neverallow问题处理(十六)

遇到 neverallow 规则问题,千万别急着去注释/剔除里面原有的规则(原生的尽量别动)。增加 allow 规则是常见的解决办法,但是随着 android 版本的升级,系统对 SELinux 的管控越来越严,增加了大量的 neverallow。一般情况下,向默认标签授予权限的做法是错误的,其中许多权限都是 neverallow 规则所不允许的。按照上面方法去添加 SELinux 可能会违反了 neverallow 规则,编译时候会报 neverallow 相关的错误。

小旭的专栏 2701

linux系统中安装htpasswd

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

qq_40021015的博客 5661

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

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_的博客 8413

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

深度学习工具包 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")

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

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

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

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

ubuntu nginx配置密码访问并下载

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

sun007700的专栏 565

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

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

weixin_33691817的博客 219

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

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

西门大盗 捉虫专家 6951

安装htpasswd命令

阿白, 1741

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

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

RisunJan的博客 830

使用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、付费专栏及课程。

余额充值
⌂ 换网址