海运的博客

Linux命令行下生成随机安全复杂密码

发布时间:April 12, 2012 // 分类:网络安全 // No Comments

1.使用openssl生成复杂密码。

openssl rand -base64 32 #密码长度32字节。
openssl rand -hex 32

2.使用gpg随机生成

gpg -a --gen-random 2 32
#-a 输出为base64
#2 安全级别 2为/dev/random  1为/dev/urandom

3.使用urandom生成复杂密码,包含各种字符。

#/bin/bash
#generate safe password
#tr -c匹配指定字符 -d删除其它字符
#执行sh safe-pass.sh 密码位数
case $1 in
*)
</dev/urandom tr -dc '1-9!@#$%^&*()a-z-A-Z' | head -c$*; echo " "
#tr -dc '[:graph:]' < /dev/urandom|fold -w32|head -n 20
;;
esac

Mysql错误 Lost connection to MySQL server at 'reading initial communication packet

发布时间:April 12, 2012 // 分类:数据库 // No Comments

一客户网站连接Mysql出现以下错误:

 Lost connection to MySQL server at 'reading initial communication packet', system error: 0

解决方法,关闭DNS反查,修改Mysql配置文件,添加以下参数并重启Mysql服务。

skip-name-resolve

Nginx设置目录密码认证/限制特定IP访问

发布时间:April 8, 2012 // 分类:Nginx,网络安全 // No Comments

网络安全无处不在,使用Nginx为您的网站后台加把锁吧。
验证界面如:
2012-04-08_071422.png
1.Nginx兼容于Apache下htpasswd生成的密钥,不过Nginx下无此工具,可以使用crypt生成密码。

perl -e 'print crypt($ARGV[0], "pwdsalt")' password ;echo ""#password请更改为您的密码

用php生成sha密码,不建议:

$user = 'test';
$pass = 'test';
$sha1 = base64_encode(sha1($pass, true));
echo $user.':{SHA}'.$sha1;

使用openssl生成sha512crypt密码,建议使用。

echo 123456|openssl passwd -6 -in - 

结果即加密后的密码,新建密钥配置谁的将用户密码以以下方式添加。

user:passwd

编辑Nginx配置文件

location ^~ /admin/ {        #特定目录
location ~ .*\.(php|php5)?$ {
allow 192.168.1.16; #允许IP
deny all; #拒绝所有
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}
auth_basic "Login";
auth_basic_user_file /passwdfile;
}

添加ip白名单跳过验证:

satisfy any;
allow 127.0.0.1;
deny all;
auth_basic "Login";
auth_basic_user_file /passwdfile;

Apache服务器安全设置

发布时间:April 7, 2012 // 分类:Apache,网络安全 // No Comments

Apache是世界上占用率最大的web服务器软件,以安装、稳定而著称,默认安装后有一些限制较为宽松,可进一步设置加固其安全。
1.隐藏版本信息:

ServerSignature off #不输出任何页脚信息
ServerTokens prod #不输出apache版本信息

2.以低权限用户运行:

User nobody
Group nobody

3.网站目录设定:

<Directory "/var/www/html">
#Options Indexes FollowSymLinks #取消目录浏览,链接到其它目录
AllowOverride None  #禁止htaccess
php_admin_value open_basedir /var/www/html/ #限制活动目录,防止跨站,多个目录以:相隔
Order allow,deny
Allow from all
</Directory>

4.隐藏php版本,编辑php配置文件php.ini,添加或修改:

expose_php Off

此内容被密码保护

发布时间:April 7, 2012 // 分类:VPN // 12 Comments

请输入密码访问

分类
最新文章
最近回复
  • 海运: 恩山有很多。
  • swsend: 大佬可以分享一下固件吗,谢谢。
  • Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
  • 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
  • 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
  • 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...
  • 孤狼: 擦。。。。apcupsd会失联 nut在冲到到100的时候会ONBATT进入关机状态,我想想办...
  • 海运: 网络,找到相应的url编辑重发请求,firefox有此功能,其它未知。
  • knetxp: 用浏览器F12网络拦截或监听后编辑重发请求,修改url中的set为set_super,将POS...
  • Albert: 啊啊啊啊啊啊啊啊啊 我太激动了,终于好了英文区搜索了半天,翻遍了 pve 论坛没找到好方法,博...