Posts Tagged ‘BSD’

定制FreeBSD内核

Posted in FreeBSD, 搬家之前 on 3月 14th, 2009 by 飘(piao2010) – Be the first to comment

参考书籍:FreeBSD 使用手册,BSD HACKS

首先进入目录

# cd /usr/src/sys/i386/conf

复制一份配置文件命名为HACKER-PIAO
# cp GENERIC HACKER-PIAO

如果说不存在这个目录的话可以进行如下操作:

#sysinstall, 选择 Configure, 然后是 Distributions、 src,选中其中的 base 和 sys。 如果您不喜欢 sysinstall 并且有一张 “官方的” FreeBSD CDROM, 也可以使用下列命令, 从命令行来安装源代码:# mount /cdrom# mkdir -p /usr/src/sys# ln -s /usr/src/sys /sys# cat /cdrom/src/ssys.[a-d]* | tar -xzvf -# cat /cdrom/src/sbase.[a-d]* | tar -xzvf -       

接下来定制内核 HACKER-PIAO 主要是参考使用手册和BSD HACKS,这里我列出一小部分设置,其它设置可以参看当前目录下的NOTES文件

makeoptions COPTFLAGS=”-O2 -pipe -funroll-loops -ffast-math”
options  DEVICE_POLLING
options  HZ=1000options  IPFIREWALL
options  DUMMYNET###远程SSH配置时请用accept
options  IPFIREWALL_DEFAULT_TO_ACCEPT
options  IPDIVERToptions  IPFIREWALL_VERBOSE
options  IPFIREWALL_VERBOSE_LIMIT=100
options  IPSTEALTH
options  ACCEPT_FILTER_DATA
options  ACCEPT_FILTER_HTTP
#options ICMP_BANDLIM      #貌似7.0不支持这个参数#防火墙和流量控制结束其它设置我不列举出来了.

其它设置我就不列举了

进入 /usr/src 目录:

# cd /usr/src
编译内核:

# make buildkernel KERNCONF=HACKER-PIAO

等待N久….如果出错可以根据提示信息修改相应配置

安装新内核:(这步还是挺快的)

# make installkernel KERNCONF=HACKER-PIAO

 

重启系统

#shutdown -r now

如果不出现错误的话就成功了。o(∩_∩)o…

半天时间就这样过去了,不过还是比较值得的,学到很多东东。

centOS

Posted in Linux, 搬家之前 on 2月 22nd, 2009 by 飘(piao2010) – Be the first to comment

  之前接触的是FreeBSD,最近想学习一下Linux,朋友推荐centOS,于是就打算在服务器上装一个跑跑。

下载安装就不说了,都挺简单的。设置好网络,配置好SSH,基本上和BSD下一致。然后准备安装软件,yum命令听说特别好用,哈哈!首先设置一下,这里采用的是科大的 http://centos.ustc.edu.cn/

步骤一:

 cd /etc/yum.repos.d

mv CentOS-Base.repo  CentOS-Base.repo.save

wget http://centos.ustc.edu.cn/CentOS-Base.repo.5

mv CentOS-Base.repo.5 CentOS-Base.repo

步骤二:

rpm –import http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5

然后yum update一下。

接下来安装软件就爽了。yum install XXX

配置软件的过程和BSD下基本一致,但是yum命令比BSD的ports更快更简单。

 

Sniffit官方文件

Posted in FreeBSD, 搬家之前 on 2月 13th, 2009 by 飘(piao2010) – Be the first to comment

 

官方的文件通俗易懂,相信有需要的朋友们一看就能明白。

#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#
*                         Sniffit V.0.3.7 Beta                                *
#                          By Brecht Claerhout                                #
*                                                                             *
#  This program is intended to demonstrate the unsafeness of TCP (currently)  #
*                 No illegal activities are encouraged!                       *
#                     Please read the LICENSE file                            #
*                                                                             *
#  Sniffit grew a little upon its original intentions and is now              #
*  extended for network debugging (UDP, ICMP, netload, etc.)                  *
#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#
*                          Libpcap library                                    *
#      This product includes software developed by the Computer Systems       #
*           Engineering Group at Lawrence Berkeley Laboratory.                *
#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#

0. Introduction, and some stuff you should know.
        0.1 Credits and contact
        0.2 Compiling
        0.3 License 
1. Programmers notes
 excuses for my incompetence
2. Use of the program
 flags and examples
3. Extra info on use
        3.1 Running interactive mode
 3.2 Forcing network devices   (*READ*)
 3.3 Format of the config file
 3.4 Loglevels
4. The output
 4.1 Normal
 4.2 Logfile
5. IMPORTANT NOTES, READ!
 this also!

——————————————————————————

0. Introduction, and some stuff you should know.
————————————————

0.3.7 (Beta). It has been a while I know. But this year has been a hell, last
year of uni, projects, thesis, …. it didn’t stop. Well that is behind us
now, the most important thing, is that I’m back working on the program again,
and intend to keep on doing it.

I hope you enjoy this beta version. Like always, I removed some bugs. There
is a new ‘logging’ feature. It is now possible to record traffic with
Sniffit and process it later! (it is completely different from the logging
done in the 0.3.6 version, that is known to some hardcore Sniffit users)
Please take a minute to skim through the text and read the passages marked
with a ‘*’, these are the new features.
(Please read BETA-TESTING)

I use the libpcap library developed at Berkeley Laboratory, for easy
porting (Read the licence).

0.1 Credits and contact
———————–

Credits go to (in order of appearance on the Sniffit scene):
    Wim Vandeputte <wvdputte@reptile.rug.ac.be>,
     best friend and UNIX guru, for support, testing and
                   providing me with a WWW site.
    Godmar Back, for fixing that kernel 1.2.X bug (Sniffit 0.1.X).
    Peter Kooiman, of Paradigm Systems Technology for providing the
                   facilities to port Sniffit, and for the endless testing
                   (although he laughs this away with “no big deal, I
                   don’t need no credits”).
                   Without him, there would have been no ports at all.
    Brooke Paul, for providing me with an SGI account.
    Qing Long, for the bash/zsh libpcap/configure script.
    Guy Gustavson, for giving me a FreeBSD account.
    Woju <woju@freebsd.ee.ntu.edu.tw>, for the ncurses SunOS/FreeBSD fixing,
                                       and for his other efforts.
    Amlan Saha <eng40607@nus.sg>, for adding Packet Generation to
               Sniffit, and adding other features (not implemented yet).
               I’m sure that in the near future you will see more of his
               work in Sniffit.
    Shudoh Kazuyuki, for changing getaddrbyname() and improving the
                     config-file interpreting.
    Fyodor <fyodor@dhp.com>, for pointing out the hideous small
           fragments problem.
    David O’Brien <obrien@nuxi.com>, for netbsd information.
    everybody, who ever mailed me with suggestions help, etc…

Also a big thanks to my Beta testers (alphabetically, I hope)…
    Charles G Stuart      <charles.stuart@juno.com>         IRIX / RedHat LINUX
    Patrick Schoppenhorst <pschoppe@thumper.indianapolis.sgi.com>          IRIX
    Shahid Mahmood        <smahmood@hns.com>            Slackware LINUX / SunOS
    Stephen Hillier       <shillier@tuns.ca>                       RedHat LINUX

    And many others who wish to be anonymous….

Suggestions and comments can be sent to:
  coder@reptile.rug.ac.be

  Brecht Claerhout
  Meulebeeksestw. 51
  8700 Tielt
  Belgium

The original distribution program can be obtained from (my site):
  http://sniffit.rug.ac.be/sniffit/sniffit.html

MIND YOU: this program is run as root, and thus could easily contain
          dangerous trojans. If you get it from the above site you can
          safely compile and use it.
          (no trojan versions are discovered yet.. it’s just a warning)

0.2 Compiling
————-

Just type ‘configure’ and then ‘make’ (if configure made it without errors).
Mind you, you can still modify some things in the ’sn_config.h’ file, but
by default all sections that can be added on your system are added.

IMPORTANT NOTES:
  1. This source code has only been tested with GNU versions of make/C
     compiler. (i.e. don’t come complaining to me if your ‘native’ system
     compiler screws up, use GNU!)
  2. curses IS NOT equal to ncurses. 
     (ncurses is available at your local sunsite mirror.)
  3. READ THE FAQ when experiencing problems.

Other stuff….
make clean  : cleans all directories for a compiling from scratch

0.3 License (this is a copy of the LICENSE file)
———–

Sniffit 0.3.7 Copyright (c) 1996-1998 Brecht Claerhout
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
   derived from this software without specific prior written permission.
4. Redistribution of source code must be conform with the ‘libpcap’
   copyright conditions, if that library is included.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR “AS IS” AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

1. Programmers notes
——————–

I wasn’t educated to be a programmer, so I write lousy code. Please forgive
me.

Still I note the use of shared memory, with Linux you should take extra
care when recompiling your kernel! Answer YES to ‘System V IPC
(CONFIG_SYSVIPC) [y]‘.

2. Use of the program
———————

(The man pages have detailed info on what parameters you can mix)
(* indicates New Features)

Options:
ONE of these is required!

  -v                Show version and exit (just added because it’s such a
                    wide spread option)
  -t <IP nr/name>   tells the sniffer to check out packets GOING TO <IP>
  -s <IP nr/name>   tells the sniffer to check out packets COMING FROM <IP>
                    You can use the ‘@’ wildcard (only IP NUMBERS of course).
                    e.g. -t 199.145.@
                         -t 199.14@
                    mind you -t @ is also a valid option.
  -i                Interactive mode, overrides all other options
* -I                Extended Interactive mode, overrides all other options
*                   Much more fun then -i, watch and enjoy…
*                   (best viewed in a xterm that is stretched wide…)
  -c <file>         Use <file> as a config file for Sniffit
                    See 3.3 for format of the config file.

  NOTE: -t or -s only apply to TCP and UDP  packages, ICMP, IP packages
        are ALL interpreted.
        Also, any selection on ports, -p only applies to TCP, UDP packages.

Parameters for all modes:
  -F <device>  force sniffit to use a network device
        (READ 3.2 ON THIS SUBJECT, IMPORTANT)
  -n           Turn  off  IP  checksum  checking. This can show you
               bogus packets.  (mind you ARP, RARP,  other  non-IP
               packets  will  show  up bogus too) (compatible with
               ALL options)
  -N        Disables all functions that Sniffit has build in, useful
               for wanting to run ONLY a plugin

Parameters for not running in -i:
  -b            does both -t and -s, doesn’t matter what function you used
                (-t or -s)
  -d            Dump mode, shows the packets on the screen in bytes (not
                like tcpdump). For test purposes. (numbers are hex)
  -a            same of ‘-d’ but outputs ASCII.
  -x            Prints extended info on TCP packets (SEQ numbers, ACK, Flags)
         Like SEQ, ACK, the flags, etc… (works wit ‘-a’, ‘-d’, ‘-s’,
         ‘-t’, ‘-b’ or on its own.)
                (Mind you it is always shown on stdout, so not logged when
                using ‘-t’, ‘-s’, ‘-b’ without another parameter)
* -R <file>     Record all traffic in <file>
*               This file can then be fed to Sniffit with the ‘-r’ option. 
* -r <file>     This option feeds the recorded <file> to Sniffit. This
*               option requires the ‘-F’ option with the correct device.
*               Suppose you log a file on a machine with ‘eth0′. When
*               feeding the logged file to sniffit, you will need to add ‘-F eth0′
*               or ‘-F eth’ to the command line.
*               It doesn’t need much explanation that using ‘-i’ or ‘-I’
*               in combination with ‘-r’ makes no sense (at this moment).
  -A <char>     When in logging mode, all non-printable chars will be
                replaced by <char>. (see note below 4.The output)
  -P protocol   specify the protocols examined (default TCP)
         possible options currently are: IP, TCP, ICMP, UDP
         They can be combined.
  -p <port>     Logs connections on …

FreeBSD:OpenSSH

Posted in FreeBSD, 搬家之前 on 2月 13th, 2009 by 飘(piao2010) – Be the first to comment

文章参考别人的o(∩_∩)o… 

客户端用密钥方式登陆到 FreeBSD SSH服务器

一、密匙认证原理简介
  密匙认证需要依靠密匙,首先创建一对密匙(包括公匙和私匙,用公匙加密的数据只能用私匙解密),把公匙放到需要远程服务器上,私钥放在客户端。这样当登录远程服务器时,客户端软件就会向服务器发出认证请求;服务器收到请求之后,先在服务器的宿主目录下寻找你的公匙,然后检查该公匙是否是合法,如果合法就用公匙加密一随机数生成所谓的“challenge”发送给客户端软件;客户端软件收到“challenge”之后就用私匙解密再把结果发送给服务器。因为用公匙加密的数据只能用私匙解密,服务器经过比较就可以知道该客户连接的合法性。

二、客户端配置
  1、下载SSHSecureShellClient,用默认方式安装。
  2、创建密钥对。单击Edit-Settings-User Authentication-keys-Generate New…生成新的公钥。

       3、检查密钥文件的读写属性。默认安装后密钥对存放路径为C:\Documents and Settings\Administrator\Application Data\SSHeys ,将私钥设置成仅允许属主有读写权,也可将它放在U盘上,使用时再导入,以确保密钥安全。

      4、在不同WIN客户机上登陆。有时需要临时在其他WIN客户机登陆服务器,这时可用上述方法安装Secure Shell Client,然后将C:\Documents and Settings\Administrator\Application Data\SSHeys目录里的文件复制到新的WIN客户机上对应目录里即可。
  注意:当不用该客户机后必须将上述目录里的文件删除,以防密钥被人盗取!!!!

三、服务端配置(服务端FB自带的Openssh)
  1、用vi编辑/etc/rc.conf,确保有以下行:
  sshd_enable=”yes
  2、在FB服务器添加新用户,并指定他属于wheel组。
  3、用vi编辑/etc/ssh/sshd_config,将FB服务器设置成密码验证方式。/etc/ssh/sshd_config文件内容有以下行:
  Port 22
  ListenAddress 10.1.1.1
  PasswordAuthentication yes
  ChallengeResponseAuthentication yes
  UsePAM yes
  UseDNS no

4、重启SSHD服务。
  #/etc/rc.d/sshd restart

5、在WINXP上运行SSH Secure Shell Client ,用密码方式登陆FB SSHD服务器,将前面创建的公钥文件xx.pub上传到用户家目录,即:
  /home/piao/xx.pub

6、把SSH Secure Shell Client格式的公钥转换成Openssl格式的公钥。
  #ssh-keygen -i -f xx.pub >> /etc/ssh/authorized_keys ;转换格式并将公钥导入到authorized_keys文件中
  #chmod 0640 /etc/ssh/authorized_key ;设置权限,使该文件仅允许属主读写
  #rm xx.pub ;删除上传的公钥

7、为了安全建议禁用密码方式访问,用vi编辑/etc/ssh/sshd_config,将FB服务器设置成密钥验证方式。
  Protocol 2
  PasswordAuthentication no
  PermitRootLogin no
  ChallengeResponseAuthentication no
  PubkeyAuthentication yes   
  AuthorizedKeysFile .ssh/authorized_keys

8、重启SSHD服务器
  #/etc/rc.d/sshd restart

9、在WINXP上运行SSH Secure Shell Client 用密钥方式登陆服务器。

 

 

附:

sshd_config 中文手册
译者:金步国

——————————————————————————–

版权声明
本文作者是一位自由软件爱好者,所以本文虽然不是软件,但是本着 GPL 的精神发布。任何人都可以自由使用、转载、复制和再分发,但必须保留作者署名,亦不得对声明中的任何条款作任何形式的修改,也不得附加任何其它条件。您可以自由链接、下载、传播此文档,但前提是必须保证全文完整转载,包括完整的版权信息和作译者声明。

其他作品
本文作者十分愿意与他人共享劳动成果,如果你对我的其他翻译作品或者技术文章有兴趣,可以在如下位置查看现有作品的列表:

金步国作品列表
BUG报告,切磋与探讨
由于作者水平有限,因此不能保证作品内容准确无误,请在阅读中自行鉴别。如果你发现了作品中的错误,请您来信指出,哪怕是错别字也好,任何提高作品质量的建议我都将虚心接纳。如果你愿意就作品中的相关内容与我进行进一步切磋与探讨,也欢迎你与我联系。联系方式:MSN: csfrank122@hotmail.com

——————————————————————————–

SSHD_CONFIG(5)            OpenBSD Programmer’s Manual           SSHD_CONFIG(5)

名称
     sshd_config - OpenSSH SSH 服务器守护进程配置文件

大纲
     /etc/ssh/sshd_config

描述
     sshd(8) 默认从 /etc/ssh/sshd_config 文件(或通过 -f 命令行选项指定的文件)读取配置信息。
     配置文件是由”指令 值”对组成的,每行一个。空行和以’#'开头的行都将被忽略。
     如果值中含有空白符或者其他特殊符号,那么可以通过在两边加上双引号(”)进行界定。
     [注意]值是大小写敏感的,但指令是大小写无关的。

     当前所有可以使用的配置指令如下:

     AcceptEnv
             指定客户端发送的哪些环境变量将会被传递到会话环境中。[注意]只有SSH-2协议支持环境变量的传递。
             细节可以参考 ssh_config(5) 中的 SendEnv 配置指令。
             指令的值是空格分隔的变量名列表(其中可以使用’*'和’?'作为通配符)。也可以使用多个 AcceptEnv 达到同样的目的。
             需要注意的是,有些环境变量可能会被用于绕过禁止用户使用的环境变量。由于这个原因,该指令应当小心使用。
             默认是不传递任何环境变量。

     AddressFamily
             指定 sshd(8) 应当使用哪种地址族。取值范围是:”any”(默认)、”inet”(仅IPv4)、”inet6″(仅IPv6)。

     AllowGroups
             这个指令后面跟着一串用空格分隔的组名列表(其中可以使用”*”和”?”通配符)。默认允许所有组登录。
             如果使用了这个指令,那么将仅允许这些组中的成员登录,而拒绝其它所有组。
             这里的”组”是指”主组”(primary group),也就是/etc/passwd文件中指定的组。
             这里只允许使用组的名字而不允许使用GID。相关的 allow/deny 指令按照下列顺序处理:
             DenyUsers, AllowUsers, DenyGroups, AllowGroups

     AllowTcpForwarding
             是否允许TCP转发,默认值为”yes”。
             禁止TCP转发并不能增强安全性,除非禁止了用户对shell的访问,因为用户可以安装他们自己的转发器。

     AllowUsers
             这个指令后面跟着一串用空格分隔的用户名列表(其中可以使用”*”和”?”通配符)。默认允许所有用户登录。
             如果使用了这个指令,那么将仅允许这些用户登录,而拒绝其它所有用户。
             如果指定了 USER@HOST 模式的用户,那么 USER 和 HOST 将同时被检查。
             这里只允许使用用户的名字而不允许使用UID。相关的 allow/deny 指令按照下列顺序处理:
             DenyUsers, AllowUsers, DenyGroups, AllowGroups

     AuthorizedKeysFile
             存放该用户可以用来登录的 RSA/DSA 公钥。
             该指令中可以使用下列根据连接时的实际情况进行展开的符号:
             %% 表示’%'、%h 表示用户的主目录、%u 表示该用户的用户名。
             经过扩展之后的值必须要么是绝对路径,要么是相对于用户主目录的相对路径。
             默认值是”.ssh/authorized_keys”。

     Banner
             将这个指令指定的文件中的内容在用户进行认证前显示给远程用户。
             这个特性仅能用于SSH-2,默认什么内容也不显示。”none”表示禁用这个特性。

     ChallengeResponseAuthentication
             是否允许质疑-应答(challenge-response)认证。默认值是”yes”。
             所有 login.conf(5) 中允许的认证方式都被支持。

     Ciphers
             指定SSH-2允许使用的加密算法。多个算法之间使用逗号分隔。可以使用的算法如下:
             “aes128-cbc”, “aes192-cbc”, “aes256-cbc”, “aes128-ctr”, “aes192-ctr”, “aes256-ctr”,
             “3des-cbc”, “arcfour128″, “arcfour256″, “arcfour”, “blowfish-cbc”, “cast128-cbc”
             默认值是可以使用上述所有算法。

     ClientAliveCountMax
             sshd(8) 在未收到任何客户端回应前最多允许发送多少个”alive”消息。默认值是 3 。
             到达这个上限后,sshd(8) 将强制断开连接、关闭会话。
             需要注意的是,”alive”消息与 TCPKeepAlive 有很大差异。
             “alive”消息是通过加密连接发送的,因此不会被欺骗;而 TCPKeepAlive 却是可以被欺骗的。
             如果 ClientAliveInterval 被设为 15 并且将 ClientAliveCountMax 保持为默认值,
             那么无应答的客户端大约会在45秒后被强制断开。这个指令仅可以用于SSH-2协议。

     ClientAliveInterval
             设置一个以秒记的时长,如果超过这么长时间没有收到客户端的任何数据,
             sshd(8) 将通过安全通道向客户端发送一个”alive”消息,并等候应答。
             默认值 0 表示不发送”alive”消息。这个选项仅对SSH-2有效。

     Compression
             是否对通信数据进行加密,还是延迟到认证成功之后再对通信数据加密。
             可用值:”yes”, “delayed”(默认), “no”。

     DenyGroups
             这个指令后面跟着一串用空格分隔的组名列表(其中可以使用”*”和”?”通配符)。默认允许所有组登录。
             如果使用了这个指令,那么这些组中的成员将被拒绝登录。
             这里的”组”是指”主组”(primary group),也就是/etc/passwd文件中指定的组。
             这里只允许使用组的名字而不允许使用GID。相关的 allow/deny 指令按照下列顺序处理:
             DenyUsers, AllowUsers, DenyGroups, AllowGroups

     DenyUsers
             这个指令后面跟着一串用空格分隔的用户名列表(其中可以使用”*”和”?”通配符)。默认允许所有用户登录。
             如果使用了这个指令,那么这些用户将被拒绝登录。
             如果指定了 USER@HOST 模式的用户,那么 USER 和 HOST 将同时被检查。
             这里只允许使用用户的名字而不允许使用UID。相关的 allow/deny 指令按照下列顺序处理:
             DenyUsers, AllowUsers, DenyGroups, AllowGroups

     ForceCommand
             强制执行这里指定的命令而忽略客户端提供的任何命令。这个命令将使用用户的登录shell执行(shell -c)。
             这可以应用于 shell 、命令、子系统的完成,通常用于 Match 块中。
             这个命令最初是在客户端通过 SSH_ORIGINAL_COMMAND 环境变量来支持的。

     GatewayPorts
             是否允许远程主机连接本地的转发端口。默认值是”no”。
             sshd(8) 默认将远程端口转发绑定到loopback地址。这样将阻止其它远程主机连接到转发端口。
             GatewayPorts 指令可以让 sshd 将远程端口转发绑定到非loopback地址,这样就可以允许远程主机连接了。
             “no”表示仅允许本地连接,”yes”表示强制将远程端口转发绑定到统配地址(wildcard address),
             “clientspecified”表示允许客户端选择将远程端口转发绑定到哪个地址。

     GSSAPIAuthentication
             是否允许使用基于 GSSAPI 的用户认证。默认值为”no”。仅用于SSH-2。

     GSSAPICleanupCredentials
             是否在用户退出登录后自动销毁用户凭证缓存。默认值是”yes”。仅用于SSH-2。

     HostbasedAuthentication
             这个指令与 RhostsRSAAuthentication 类似,但是仅可以用于SSH-2。推荐使用默认值”no”。
             推荐使用默认值”no”禁止这种不安全的认证方式。

     HostbasedUsesNameFromPacketOnly
             在开启 HostbasedAuthentication 的情况下,
             指定服务器在使用 ~/.shosts ~/.rhosts /etc/hosts.equiv 进行远程主机名匹配时,是否进行反向域名查询。
             “yes”表示 sshd(8) 信任客户端提供的主机名而不进行反向查询。默认值是”no”。

     HostKey
             主机私钥文件的位置。如果权限不对,sshd(8) 可能会拒绝启动。
             SSH-1默认是 /etc/ssh/ssh_host_key 。
             SSH-2默认是 /etc/ssh/ssh_host_rsa_key 和 /etc/ssh/ssh_host_dsa_key 。
             一台主机可以拥有多个不同的私钥。”rsa1″仅用于SSH-1,”dsa”和”rsa”仅用于SSH-2。

     IgnoreRhosts
             是否在 RhostsRSAAuthentication 或 HostbasedAuthentication 过程中忽略 .rhosts 和 .shosts 文件。
             不过 /etc/hosts.equiv 和 /etc/shosts.equiv 仍将被使用。推荐设为默认值”yes”。

     IgnoreUserKnownHosts
             是否在 RhostsRSAAuthentication 或 HostbasedAuthentication 过程中忽略用户的 ~/.ssh/known_hosts 文件。
             默认值是”no”。为了提高安全性,可以设为”yes”。

     KerberosAuthentication
             是否要求用户为 PasswordAuthentication 提供的密码必须通过 Kerberos KDC 认证,也就是是否使用Kerberos认证。
             要使用Kerberos认证,服务器需要一个可以校验 KDC identity 的 Kerberos servtab 。默认值是”no”。

     KerberosGetAFSToken
             如果使用了 AFS 并且该用户有一个 Kerberos 5 TGT,那么开启该指令后,
             将会在访问用户的家目录前尝试获取一个 AFS token 。默认为”no”。

     KerberosOrLocalPasswd
             如果 Kerberos 密码认证失败,那么该密码还将要通过其它的认证机制(比如 /etc/passwd)。
             默认值为”yes”。

     KerberosTicketCleanup
             是否在用户退出登录后自动销毁用户的 ticket 。默认值是”yes”。

     KeyRegenerationInterval
             在SSH-1协议下,短命的服务器密钥将以此指令设置的时间为周期(秒),不断重新生成。
             这个机制可以尽量减小密钥丢失或者黑客攻击造成的损失。
             设为 0 表示永不重新生成,默认为 3600(秒)。

     ListenAddress
             指定 sshd(8) 监听的网络地址,默认监听所有地址。可以使用下面的格式:

                   ListenAddress host|IPv4_addr|IPv6_addr
                   ListenAddress host|IPv4_addr:port
                   ListenAddress [host|IPv6_addr]:port

             如果未指定 port ,那么将使用 Port 指令的值。
             可以使用多个 ListenAddress 指令监听多个地址。

     LoginGraceTime
             限制用户必须在指定的时限内认证成功,0 表示无限制。默认值是 120 秒。

     LogLevel
             指定 sshd(8) 的日志等级(详细程度)。可用值如下:
             QUIET, FATAL, ERROR, INFO(默认), VERBOSE, DEBUG, DEBUG1, DEBUG2, DEBUG3
          &nbsp …

freebsd:socks5代理服务器

Posted in FreeBSD, 搬家之前 on 2月 12th, 2009 by 飘(piao2010) – Be the first to comment

因为配置很简单,算是原创吧。o(∩_∩)o…

freebsd# whereis socks5
socks5: /usr/local/bin/socks5 /usr/local/man/man1/socks5.1.gz /usr/ports/net/socks5
freebsd# cd /usr/ports/net/socks5

然后make install

完成后/etc/rc.conf 增加一条:socks5_enable=”yes”

配置文件:/usr/local/etc/socks5.conf

#指定SOCKS v5绑定的ip地址和监听的端口。如果不指定绑定的IP将使用0.0.0.0
set SOCKS5_BINDINFC 0.0.0.0:1080
#忽略ident请求。当客户机没有运行identd时,使用SOCKS5_NOIDENT将降低超时值
set SOCKS5_NOIDENT
#指定连接停顿最长时间。超过最大值后,socks5断开连接
set SOCKS5_TIMEOUT 15
#socks5将接受SOCKS V4 协议的请求,默认不接受
set SOCKS5_V4SUPPORT
#指定同时存在的最大子进程数,Socks5预设为64
set SOCKS5_MAXCHILD 6
#指定密码文件
set SOCKS5_PWDFILE /usr/local/etc/socks5.passwd
#对所有的客户连接都使用username/password用户认证方法
auth - - u
#允许来自192.168.1.x的任何经过用户认证的连接
permit u - 192.168.1. - - - -

认证文件/usr/local/etc/socks5.passwd

格式 username password

         username2 password2

配置完成以后启动服务

#/usr/local/etc/rc.d/socks5 start

 

freebsd:Nginx+php+mysql

Posted in FreeBSD, 搬家之前 on 2月 10th, 2009 by 飘(piao2010) – Be the first to comment

文章是参考别人的,本人是在原先lighttpd+fastcgi(php)+mysql环境下直接安装nginx,然后修改相关配置文件/usr/local/etc/nginx/nginx.conf

location / {

root    /usr/local/www/nginx;

index    index.php index.html index.htm;

}

location ~ \.php$ {

fastcgi_pass    127.0.0.1:9000;

fastcgi_index   index.php;

fastcgi_param     SCRIPT_FILENAME     /usr/local/www/nginx$fastcgi_script.name;#PHP文件所在目录

include      fastcgi_params;

}

本来是很简单的一个过程,启动的时候出现了问题,unknown “fastcgi_script” variable

然后只能把

fastcgi_param     SCRIPT_FILENAME     /usr/local/www/nginx$fastcgi_script.name;

修改成

fastcgi_param     SCRIPT_FILENAME     /usr/local/www/nginx;

启动时候是不报错了,但是访问PHP文件出错nginx No input file specified

结果在网上找了一堆资料搞了半天,很多提到php.ini里面的相关设置。

cgi.fix_pathinfo=1
       doc_root=

我把能试的都试了,还是不行。又有人说是PHP文件的在目录的权限问题,最后设置成777了还是不行。。。这下郁闷了,

汗死了。。。(就这样浪费了两个多小时)

最后突然发现有的文章

fastcgi_param     SCRIPT_FILENAME   这里用的是$fastcgi_script_name

然而我参考的很多文章用的却是$fastcgi_script.name

很可能出错就是在这里了。立马修改成$fastcgi_script_name

重启nginx果然没有报错,访问php文件也正常了。看来是一篇文章出错,然后接着一堆都跟着出错。。。所以今后得细心一点,因为一个小错误导致浪费这么多时间。

 

cd /usr/ports/www/nginx
make install clean

echo ‘nginx_enable=”YES” >> /etc/rc.conf
cd /usr/ports/lang/php5
#选择支持 fastCGi
make config
make install clean
cd /usr/ports/lang/php5-extensions/
make config
make install clean

#安装 spawn-fcgi

pkg_add -r -v lighttpd
cd /usr/local/bin/
cp spawn-fcgi ../
# 找到安装的版本
pkg_info
# 删除掉lighttpd
pkg_delete lighttpd-1.4.18_1
cp ../spawn-fcgi spawn-fcgi

/usr/local/etc/nginx/nginx.conf

location / {

root    /usr/local/www/nginx;

index    index.php index.html index.htm;

}

location ~ \.php$ {

fastcgi_pass    127.0.0.1:9000;

fastcgi_index   index.php;

fastcgi_param     SCRIPT_FILENAME     /usr/local/www/nginx$fastcgi_script_name;

include      fastcgi_params;

}

先别急着启动nginx

先启动php的fastcgi模式

# /usr/local/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/local/bin/php-cgi

参数说明: a 127.0.0.1 : php-fcgi所绑定的web服务器ip

p 9000: nginx连接spawn-fcgi的端口.

u www : 用户名.

g www : 用户组

 

#ee /etc/rc.local

/usr/local/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -C 25(进程数) -f /usr/local/bin/php-cgi

这样spawn-fcgi就能开机自启动了

在启动spawn-fcgi之后再启动nginx,然后就可以访问php文件了。