2013
02
21
09:25

FreeBSD安裝sshguard-ipfw

請先完成ipfw設置

cd /usr/ports/security/sshguard-ipfw;make install clean

在/etc/syslog.conf 中

把

#auth.info;authpriv.info |exec /usr/local/sbin/sshguard

註解去掉

也可以自由設定鎖定時間

例如:

auth.info;authpriv.info |exec /usr/local/sbin/sshguard -a 5 -p 7200 -s 3600

(a:失敗多少次 p:被擋多久(秒) s:多少秒忘記攻擊)

最後/etc/rc.d/syslogd restart

接著你可以tail -f /var/log/auth.log,然後用putty連線,密碼請故意打錯四次,就會出現:

Jan 26 13:31:05 earth sshguard[40059]: Blocking 210.71.11.116:4 for >420secs: 4 failures over 2 seconds.

解除鎖定:

使用另一個IP登入

ipfw show

ipfw delete xxxxx

2013
02
21
09:11

FreeBSD安装pure-ftpd

cd /usr/ports/ftp/pure-ftpd

make install clean(選UTF-8)

cd /usr/local/etc

cp pure-ftpd.conf.sample pure-ftpd.conf

vi /etc/rc.conf

加入

pureftpd_enable=”YES”

ftp傳輸檔案時是有特定的port,

如果防火牆有擋port,可以自行設定ftp檔案傳輸的port

vi /usr/local/etc/pure-ftpd.conf

將PassivePortRange這行改成

PassivePortRange 65000 65500

啟用ftp

/usr/local/etc/rc.d/pure-ftpd start

2013
02
21
09:09

FreeBSD Samba安装及设定

cd /usr/ports/net/samba34

make install clean

(選擇 LDAP、ADS、CUPS、WINBIND、ACL_SUPPORT、SYSLOG、UTMP)

vi /etc/rc.conf

samba_enable=”YES”

vi /usr/local/etc/smb.conf

#加入工作群組

workgroup = WORKGROUP

#主機名稱

server string = %h Samba Server

(%h為主機名稱變數)

#設定使用者家目錄

原為:

[homes]

comment = Homes Directories

browseable = no

writable = yes

更改為:

[homes]

comment = Home directory for %u on %h

browseable = no

writable = yes

path = /usr/home/%u/

valid users = %S

#設定共享資料夾

[public]

comment = %h Shared Public Directory

path = /usr/home/samba/public

force directory mode = 0777

force create mode = 0777

force group = nobody

force user = nobody

public = yes

writeable = yes

read only = no

#測試Samba conf中語法有無錯誤

/usr/local/bin/testparm | more

mkdir /usr/home/samba

mkdir /usr/home/samba/public

chmod 777 /usr/home/samba/public

#新增Samba帳戶

使用者必須同時設定兩種帳號: FreeBSD 的使用者帳號、 Samba 的使用者帳號 才能正常登入 Samba 伺服器。

smbpasswd -a 帳號

/usr/local/etc/rc.d/samba restart

#個別設定資料夾設定

[aaa]

comment = aaa

path = /home/samba/my2075/aaa

valid users = aaa, admin2075

write list = aaa, admin2075

browseable = No

[bbb]

comment = bbb

path = /home/samba/my2075/bbb

valid users = bbb, admin2075

write list = bbb, admin2075

browseable = No

[ccc]

comment = ccc

path = /home/samba/my2075/ccc

valid users = ccc, admin2075

write list = ccc, admin2075

browseable = No

#samba變數

%S: 取代目前的「資源名稱」,所謂的「資源名稱」就是在 [ ] 裡面的內容。ex: valid users = %S

%U: 代表目前登入的使用者的使用者名稱。

%m: 代表 Client 端的 NetBIOS 名稱。

%g: 代表登入的使用者的群組名稱。

%M: 代表 Client 端的 Internet 主機名稱,就是 HOSTNAME。

%L: 代表 SAMBA 主機的 NetBIOS 名稱。

%h: 代表目前這部 SAMBA 主機的 HOSTNAME。

%H: 代表使用者的家目錄。

%I: 代表 Client 端的 IP。

%T: 代表目前的日期與時間。

#Samba 使用下列的通訊埠:

Port 135/TCP – used by smbd

Port 137/UDP – used by nmbd

Port 138/UDP – used by nmbd

Port 139/TCP – used by smbd

Port 445/TCP – used by smbd

#Windows網路芳鄰切換使用者

進cmd模式

net use * /delete

2013
02
21
09:05

FreeBSD MySQL忘记密码

今天使用時出現

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (61)

其實是忘記密碼啦XDD

#背景執行mysql安全模式

mysqld_safe -u root –skip-grant-tables &

#登入mysql(不用密碼)

mysql -u root -p

>use mysql

>UPDATE user SET password=password(‘這裡輸入你的密碼’) where user=’root’;

>FLUSH PRIVILEGES;

>exit

/usr/local/etc/rc.d/mysql-server restart

2013
02
21
08:59

FreeBSD安裝phpmyadmin

cd /usr/ports/databases/phpmyadmin

make install clean

cp -r /usr/local/www/phpMyAdmin /usr/local/www/apache22/data/phpmyadmin

cd /usr/local/www/apache22/data/phpmyadmin

cp config.sample.inc.php config.inc.php

chmod 644 config.inc.php

2013
02
20
15:44

在Debian里面用quota配置磁盘限额

实现磁盘配额限制步骤:

1. 内核里面打开了配额的支持,绝大部分发行版都打开的

2. 以配额方式加载文件系统

3.安装配额软件:

4.配置配额

原/etc/fstab的一项:

/dev/hda1 /home ext2 defaults 1 1

做如下修改:

/dev/hda1 /home ext2 defaults,usrquota 1 1

如何是对组限制就将usrquota改为grpquota

重新加载文件系统:

mount -o remount,usrquota /home

加载内核模块,并让其开机的时候也会自动加载

modprobe quota_v2

echo ‘quota_v2’ >> /etc/modules

我们要在启用配额的分区创建文件并且限制root才能读写

touch /home/aquota.user

touch /home/aquota.group

chmod 600 /home/aquota.user /home/aquota.group

现在来安装quota软件:

apt-get install quota quotatool

如果不想重起机器来打开磁盘配额

quotacheck -vagum

现在到最后一步了,假设我们要对系统里的某个用户skx进行限制配额:

quotatool -u skx -bq 200M -l ‘250 Mb’ /home

系统管理员可以用如下命令看到 磁盘配额

repquota /home

如果想把一个用户的限制取消只用把他的限制配额设为0

对了,如果是20G,那就要写20000M,quotatool好像不认 20G的。

收工~~

其实现在一般情况下也用不到这个磁盘限额。

2013
02
17
16:18

Linux服务器一键安装包

CentminMod

http://centminmod.com/

Nginx Auto Installer – PHP – MySQL

http://serversreview.net/nginx-auto-installer-php-mysql

TuxLite

http://tuxlite.com/

https://github.com/Mins/TuxLite

Minimal & Minstall & Server

https://github.com/maxexcloo/

TigersWay

https://github.com/TigersWay/VPS

Debian-Server

https://github.com/mikegioia/Debian-Server

LNMP-xcache-PHPMyAdmin

https://github.com/AhmadShamli/LNMP-xcache-PHPMyAdmin

Nginx-Setup-Script

https://github.com/mikemansell/Nginx-Setup-Script

LNMPA

https://github.com/XWay/LNMPA

NGinxAutoInstall.sh

https://github.com/nicolargo/debianpostinstall

VladGh.com-LEMP

https://github.com/vladgh/VladGh.com-LEMP/tree/next

https://github.com/scott23/VladGh.com-LEMP/tree/update

lowendscript

https://github.com/jkilgore/lowendscript

https://github.com/sotiri/lowendscript

https://github.com/ilevkov/lowendscript

小朱的两个

http://www.centos.bz/lnmp/

http://www.centos.bz/lamp/

QLNMP

http://qlnmp.forum.openfans.org/

http://code.google.com/p/qlnmp/

Linux + Apache + Nginx + MySQL + PHP Auto Install Script

https://github.com/wangyan/lanmp

LEMP

http://bbs.linuxtone.org/thread-1582-1-1.html

http://docs.linuxtone.org/autoinstall/

AceLNMP

http://code.google.com/p/acelnmp/

lnmp-project

http://code.google.com/p/lnmp-project/downloads/list

Centos,Debian

http://code.google.com/p/lnmp-auto-install/

2013
02
17
10:22

debian 6 安装vnc+xfce4 教程

debian6 不得不说,非常好的系统,默认安装的时候,不安装图形,安装一些基本的包后,以后如果想安装图形,远程管理什么的,可以安装xfce这个桌面,非常小,然后把中文安装上,非常爽。安装的步骤如下:

apt-get install xfonts-intl-chinese xfonts-wqy ttf-wqy-zenhei ttf-wqy-microhei

apt-get install vnc4server xfce4

安装完成以后,配置下vnc,让vnc 开机自动启动,并设置一个vnc的连接密码

终端输入vncpasswd ,提示输入密码即可

远程访问客户端可以用vncviewer ,但在访问前还需修改一个 VNC 的 xstartup 文件,否则没有Xfce图像界面

vim ~/.vnc/xstartup

附我的 xstartup 文件

#!/bin/sh

# Uncomment the following two lines for normal desktop:

# unset SESSION_MANAGER

# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup

[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources

xsetroot -solid grey

#vncconfig -iconic &

#x-terminal-emulator -geometry 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &

#x-window-manager &

xfce4-session &

然后创建一个启动脚本

vim /etc/init.d/vncserver

#! /bin/sh

export USER=”root”

export PATH=”/usr/local/bin:/usr/bin:/bin:/usr/bin/X11″

NAME=vncstart

start()

{

su – $USER -c”vncserver :5″

}

stop()

{

su – $USER -c”vncserver -clean -kill :1″

}

case “$1” in

start)

echo -n “Starting Xvnc: ”

start

;;

stop)

echo -n “Stopping Xvnc ”

stop

;;

restart)

echo -n “Restarting Xvnc ”

stop

start

;;

****)

echo “Usage: /etc/init.d/$NAME {start|stop|restart}”

exit 1

;;

esac

exit 0

创建保存,设置为可执行,并加入到服务列表

chmod +x /etc/init.d/vncserver

update-rc.d vncserver defaults

然后用windows的vnc客户端连接,连接的端口是5905 ,密码就是你刚才设置的