免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: minok
打印 上一主题 下一主题

菜鸟100问 [复制链接]

论坛徽章:
0
171 [报告]
发表于 2007-01-13 14:09 |只看该作者

FreeBSD优化手记

FreeBSD优化手记

ipfw+natd

升级源码树

安装cvsup
进入:/usr/ports/net/cvsup
make clean
make deinstall
make install
make clean

即可

升级系统源码树及ports

更新/usr/share/examples/cvsup目录下stand-cvsup和ports-cvsup文件,并执行cvsup –g –L2 standard-supfile和cvsup –g –L2 ports-cvsup两个文件,升级ports树﹔

其中 *default host=cvsup.FreeBSD.org

升级操作系统

进入/usr/src
执行make world

开始重新编译内核

cd /sys/i386/conf里面,cp GENERIC NEW,再ee NEW优化内核,注意加入下面的内容

#disable ctrl+alt+delete
options SC_DISABLE_REBOOT

#quota limit
#options QUOTA

#ipfw support
options IPFIREWALL
options DUMMYNET
options HZ=3000
options IPDIVERT
options IPFIREWALL_VERBOSE
options IPFIREWALL_VERBOSE_LIMIT=100
options IPSTEALTH
options TCP_DROP_SYNFIN
options IPFIREWALL_DEFAULT_TO_ACCEPT
options ICMP_BANDLIM

options ACCEPT_FILTER_DATA
options ACCEPT_FILTER_HTTP

#ipfilter support
#options IPFILTER
#options IPFILTER_LOG
#options IPFILTER_DEFAULT_BLOCK

# SUPPORT NAT   增加地址转换功能
options   IPFIREWALL
options   IPDIVERT
options   IPFIREWALL_DEFAULT_TO_ACCEPT

再执行
/usr/sbin/config onlinecq
cd ../../compile/onlinecq
make depend
make
make install

重新启动服务器
到此为止,服务器操作系统及内核升级成功
reboot

优化FREEBSD
检查升级情况
使用ssh进入系统,使用uname –a 可以查到是否升级成功﹔

打开防火墙
更新rc.conf里面的设置,加上:
inetd_enable="YES"
natd_interface="rl0"    #rl0在地址转换中指对外网卡
natd_enable="YES"
firewall_enable="YES"
#firewall_type="OPEN"  #此处的type指的是防火墙的类型

#enable_quotas="YES"
#check_quotas="YES"
firewall_enable="YES"
firewall_script="/etc/rc.firewall"
firewall_type="/etc/ipfw.rules" #create it!
firewall_quiet="NO"
firewall_logging_enable="YES"
log_in_vain="NO"
tcp_drop_synfin="NO"
tcp_restrict_rst="YES"
icmp_drop_redirect="YES"

#记得在/etc/下创建  ipfw.rules文件
添加以下规则
cat /etc/ipfw.rules
#add all from any to any
add divert natd all from any to any via rl0
add pass all from any to any

保存退出,reboot  防火墙启动会自动加载etc/ipfw.rules规则库

规则库在更新后,执行  sh /etc/rc.firewall 则会加载规则

提示:ipfw: bad arguments, for usage summary ``ipfw''
              出现上述错误主要是ipfw.rules规则库语法出现错误造成的

重起后即可实现ipfw+natd 功能

对防火墙实现策略可通过对/etc/ipfw.rules文件编辑完成

来源: http://www.bigsea.com.cn/?action=show&id=187

论坛徽章:
0
172 [报告]
发表于 2007-01-13 14:13 |只看该作者

FreeBSD5.x--6.x 安装(Web+Ftp+Ipfw)优化

FreeBSD5.x--6.x 安装(Web+Ftp+Ipfw)优化.

同步stable系统源代码和ports代码,然后编译、定制内核
为了加快搜索速度建议修改 make.conf 文件
#ee /etc/make.conf //修改/etc/make.conf文件 设定首先尝试从国内的freebsd镜像站下载软件,在后面加入 :
MASTER_SITE_OVERRIDE=ftp://ftp.freebsdchina.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}/
cd /usr/ports/net/cvsup-without-gui
make install clean (速度慢,建议:sysinstall 的CD或FTP方式安装)
系统安装完后的第一步,是进行CVSUP,立刻同步你的src源代码和ports代码。
cd /usr/src/share/examples/cvsup
ee stable-supfile (编辑升级服务器,建议使用国内的如:cvsup.cn.freebsd.org)
cvsup -g -L 2 stable-supfile   同步代码 stable
cvsup -g -L 2 -h ftp.freebsdchina.org ports-supfile 可以代替上面兰色部分
ee ports-supfile  (编辑升级服务器,建议使用国内的如:cvsup.cn.freebsd.org)
cvsup -g -L 2 ports-supfile   同步PORTS代码
cvsup -g -L 2 -h ftp.freebsdchina.org ports-supfile可以代替上面兰色部分
至此,所有的代码升级完毕。下面开始编译内核.
*************************************************************************
5.4版:cd /usr/src
make buildworld  编译内核
make installworld  安装内核
即可更新系统为最新版,随后就可以重启机器了。Reboot
*************************************************************************

推荐使用下面的方法 :
编译安装系统流程:(建议在单用户模式下进行)
# make -j4 buildworld
# make -j4 buildkernel
# make -j4 installkernel
#mergemaster -p
#make -j4 installworld
#mergemaster -i  (-i 不提示)
# reboot

  启动到单用户模式可用# shutdown now命令或重新启动系统,在提示符处使用 boot -s,进入单用户模式。再在 shell 提示符处执行:
# fsck –p
# mount -u /
# mount -a -t ufs
# swapon -a
这会检查文件系统,重新装载 / 为读/写,参考 /etc/fstab 装载其它所有的 UFS 文件系统,然后打开交换 (swapping) 开关。注意: 如果您的 CMOS 时钟是设置为本地时间,而不是 GMT (如果 date(1) 命令输出不能显示正确的时间和地区也有确有其事), 您可能也需要执行下边的命令:
# adjkerntz -i
这样可以确定您正确的本地时区设置──不这样做, 您以后可能会碰到一些问题。
其中下面的可以在普通状态下执行:
make buildworld  推荐使用:  make -j4 buildworld (加速,顶多4个线程)
make buildkernel
make installkernel
reboot 重新启动  
在 installkernel 成功完成之后, 您需要引导到单用户模式(选择4) (举例而言, 可以在加载器提示后输入 boot -s)。 接下来执行:
改为单用户模式
方法1.从运行的系统里,以超级用户方式执行:
# shutdown now
这样就会转换到单用户模式。
方法2.重启系统,在启动提示符处,输入boot -s 标识。系统就会启动单用户。再在 shell 提示符处执行:
# fsck -p
# mount -u /
# mount -a -t ufs
# swapon -a
这会检查文件系统,重新装载 / 为读/写,参考 /etc/fstab 装载其它所有的 UFS 文件系统,然后打开交换 (swapping) 开关。
注意: 如果您的 CMOS 时钟是设置为本地时间,而不是 GMT (如果 date(1) 命令输出不能显示正确的时间和地区也有确有其事), 您可能也需要执行下边的命令:
# adjkerntz -i
这样可以确定您正确的本地时区设置──不这样做, 您以后可能会碰到一些问题。
mergemaster –p  创建临时工作目录 (选择:d )
cd /usr/src
make installworld  安装新内核
mergemaster  更新系统配置文件(注意备份 /etc 等重要目录)
reboot
最好删除 /usr/obj ,防止影响下次编译
cd /usr/obj
chflags -R noschg *
rm -rf *
下面可以进行新的编辑了。呵呵。。。。。。。
启动后定制内核:
options MAXCONS=4 #虚拟控制台数量为4个,已经够用了
options SC_DISABLE_REBOOT #禁止按ctrl+alt+del来进行重新启动
options SC_NO_SYSMOUSE #不使用鼠标

# cd /usr/src/sys/i386/conf
# mkdir /home/bak
# cp GENERIC /home/bak/XPDD   
# ln -s /home/bak/XPDD (快捷方式)备份一个内核XPDD ,然后编辑XPDD(快捷方式),然后再安装定制的XPDD
先备份旧内核程序:
cd /boot
#cp -R kernel kernel.old

编译和安装新内核
  如果您想建立一个定制内核,而且已经有了配置文件,只需象这样使用 KERNCONF=MYKERNEL:
#   cd /usr/src
#   make -j4 buildkernel KERNCONF= XPDD
#   make -j4 installkernel KERNCONF= XPDD

4.9 重启动系统
#   shutdown -r now
4.10 安装新系统
# make -j4 installworld

来源: http://tl.xpdd.net/redirect.php? ... post&highlight=

论坛徽章:
0
173 [报告]
发表于 2007-01-13 17:51 |只看该作者

FreeBSD 802.1x下认证

来源: http://my.opera.com/boyu/blog/show.dml/233387

FreeBSD 802.1x下认证

学校使用的是锐捷(原“实达”)的 802.1x认证方案。
和所有高校的其他方案类似,且都有“亲”windows 的做法。

当然,有人不满于此,分析了锐捷的认证过程并最终实现了GNU/LINUX 下的方案。
即最初的 Mento supplicnat ,以及在其基础上修改的 mystar。

在 FreeBSD 下,你可以经由下面给出的附件自行编译。
附件里面即最新的mystar的源代码,编译之前你必须确保:
1.预装好 libnet 以及 libpcap # 源码静态编译所需链接库
2.预装好 gmake # mystar 的 makefile 文件的缘故

使用 gmake 编译完成后得到mystar , mystar.conf两个文件。
你必须以 root (或sudo)运行,同时确保两个文件处于同一文件夹。# mystar 由当前文件夹读取配置信息

当然,你得修改 mystar.conf 里面的 name 以及 password 为你自己的帐号信息,
同时,nic 里要明确给出你的网卡标识,比如“rl0”等,ifconfig 便知。

最后,GOOD LUCK。

sucha_mod_mystar.tar

16.76 KB, 下载次数: 28

论坛徽章:
0
174 [报告]
发表于 2007-01-13 17:53 |只看该作者
研究下Windows下的认证程序下的客户端,原来是在标准802.1x的数据包后加入了以下数据:

/////////////////////////////////////////////////////////////////////////////////////

static byte RuijieExtra[144] = { //Ruijie OEM Extra by soar @ [url]http://bbs.53ucity.com/
////////////////////////////////////////////////////////////////////////////
//
// OEM Extra
// 0 --> 22
0x00,0x00,0x13,0x11, // Encode( 0x00,0x00,0x13,0x11 ) Ruijie OEM Mark
0x01, // Encode( 0x01/00 )
0x00,0x00,0x00,0x00, // Encode( IP )
0x00,0x00,0x00,0x00, // Encode( SubNetMask )
0x00,0x00,0x00,0x00, // Encode( NetGate )
0x00,0x00,0x00,0x00, // Encode( DNS )
0x00,0x00, // Checksum( )
// 23 --> 58
0x00,0x00,0x13,0x11,0x38,0x30,0x32,0x31,0x78,0x2E,0x65,0x78,0x65,0x00,0x00,0x00, // ASCII 8021x.exe
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //
0x00,0x00,0x00,0x00,
// 59 --> 77
0x02,0x32,0x00,0x00, // 8021x.exe File Version (2.5.00)
0x00, // unknow flag
0x00,0x00,0x13,0x11,0x00,0x28,0x1A,0x28,0x00,0x00,0x13,0x11,0x17,0x22, // Const strings
// 78 --> 118
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,// 32bits spc. Random strings
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F, // 32bits spc. Random strings
0x00,0x00,0x13,0x11,0x18,0x06,0x00,0x00,0x00, // Const strings
// 119
0x00, // DHCP and first time flag

// V2.56 (and upper?) added
// 120 -->
//0x1A,0x0E,0x00,0x00,0x13,0x11,0x2D,0x08, // Const strings
// 128 --> 141
//0x00,0x00,0x00,0x00,0x00,0x00, // True NIC MAC
//0x1A,0x08,0x00,0x00,0x13,0x11,0x2F,0x02 // Const strings
};

/////////////////////////////////////////////////////////////////////////////////////

其中 32 为的随机数在发送用户名和密码时为客户端的验证 MD5 Hash ,关于这 32 位数字的生成方法如下(VC++ MFC):

//
//
///////////////////////////////////////////////////////////////////
//
//

// Ruijie 8021x.exe 客户端验证及其完整性验证(版本 V2.45 /2.50 /2.56 )
//
// 有些变态用了 8 次 MD5 算法检校 0x00401000h --> 0x00421000h 程序段
// (每段长0x4000h),每分段前加入了服务器返回的 MD5 串,最后得到的
// 8组 MD5 Hash 再和服务器返回的 MD5 串做运算生成 0x90h 的表 TableC
// 再作一次 MD5 运算。
//
//////////////////////////////////////////////////////////////////
//
// 严正声明:
// 本算法仅供学习和研究 8021x 认证客户端程序之用,
// 严禁他用,其他用途产生的后果本人一概不以负责 !
//
// -- by soar @ 2006/07/01
// [url]http://bbs.53ucity.com/
//////////////////////////////////////////////////////////////////
//
//

//产生特殊随机字符串
CString CMentoSupplicantDlg::Randstr(bool flag)
{
CString strFormat,strRandom;
int a,b,c,d,e;
unsigned t;

strFormat="%X%X%X%X%X%X9884773d9f46acafd7839eb38789088ac9534";
if (flag){strFormat="%X%X%X%X%X%X388498639f49ebaca773dfd78789088ac9534";}

t=time(NULL);
srand(t);
a=rand();
b=rand();
c=rand();
d=rand();
e=rand();

strRandom.Format(strFormat,a,b,c,d,e,t);
return strRandom;
}

//验证算法
void CMentoSupplicantDlg::Clog()
{
int i,j=0;
int nLength = 0; //number of bytes read from the file
int nBufferSize=0x4000; //checksum the file in blocks of bytes

CFileVersionInfo fvi;
CString strRJVersionInfo;

if (fvi.Create(strRJFileN)){
bool notfindflag=true;
strRJVersionInfo=fvi.GetFileVersion();
strRJVersionInfo.Replace(" ","");
if (strRJVersionInfo.Find("2,45,0,0")==0){
nBufferSize=0x3E00;
notfindflag=false;
//PrintOutput("V2,45,0,0");
}
if (strRJVersionInfo.Find("2,50,0,0")==0){
nBufferSize=0x4000;
notfindflag=false;
//PrintOutput("2,50,0,0");
}
if (strRJVersionInfo.Find("2,51,0,0")==0){
nBufferSize=0x4200;
notfindflag=false;
//PrintOutput("2,51,0,0");
}
if (strRJVersionInfo.Find("2,56,0,0")==0){
nBufferSize=0x4A00;
notfindflag=false;
//PrintOutput("2,56,0,0");
}
if (notfindflag){
PrintOutput(" ** 不支持的Ruijie客户端版本!。");
}
}

//


BYTE Buffer1[0x5000]; //buffer for data read from the file
BYTE Buffer2[0x5000]; //buffer for data to MD5 Checksum
BYTE md5rev[16]; //buffer for receive MD5 from the Server
BYTE *md5Dig1,*md5Dig2;
ULONGLONG lActual;

static byte TableC[0x90]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

// Authentication Server MD5 Hash
for (i=0;i<16;i++)
md5rev=bMD5Source[24+i];

// Tranform to TableC
TableC[0]=md5rev[0];
for (i=1;i<8;i++){
TableC[i*18-1]=md5rev[i*2-1];
TableC[i*18]=md5rev[i*2];}
TableC[143]=md5rev[15];

// Check 8021x.exe, Exist ?
if (CFile::GetStatus(strRJFileN,FileStatus)==FALSE){
//PrintOutput(" >> 无法找到“8021x.exe”!!!");
//PrintOutput(" 请复制到本程序目录下,");
//PrintOutput(" 否则无法生成Ruijie客户端信息。");

//return a 32 bits Random string
strMD5Hash=Randstr(false);

return;
}

// Open the 8021.exe for reading.
CFile File(strRJFileN, CFile::modeRead | CFile::shareDenyWrite | CFile::typeBinary);

try
{
//checksum the file in blocks of xxxx bytes
lActual=File.Seek (0x1000,CFile::begin);
while ((nLength = File.Read( Buffer1, nBufferSize )) > 0 && j<8)
{

for (i=0;i<16;i++){
Buffer2=md5rev;}
for (i=0;i<nBufferSize;i++){
Buffer2[i+16]=Buffer1;}

//Return each block MD5 Hash
md5Dig1=ComputeHash(Buffer2,nBufferSize+16);

for (i=0;i<16;i++){
TableC[18*j+i+1]=md5Dig1;}
j++;

}//end of while

// PrintOutput( "MD5_1to8_Done!");
md5Check=ComputeHash(TableC,144);

//not the best work....
CString strTemp,strFormat;
strMD5Hash="";
for (i=0;i<16;i++){
if (md5Check) {//if outside
if (md5Check>0x0f){
strFormat="%x";}
else{
strFormat="0%x";}

strTemp.Format(strFormat,md5Check);
strMD5Hash=strMD5Hash+strTemp;}
else{//if outside
strMD5Hash=strMD5Hash+"00";}//end of if outside

}//end of for
PrintOutput(" >> Ruijie “8021x.exe” 验证 MD5: ");
PrintOutput(" "+strMD5Hash);
return;
}//end of try

//catche Exception error for debug only
catch (CFileException* e )
{
#ifdef _DEBUG
afxDump << "File could not be opened " << e->m_cause << "\n";
#endif
throw e;
}//end of catch
}//end of fuction

//
//
/////////////////////////////////////////////////////////////////////////
//
//


Windows 下的客户端已经成功通过认证服务器的完整性检查和 Ruijie 发送的数据一致^_^

论坛徽章:
0
175 [报告]
发表于 2007-01-13 18:00 |只看该作者

ssh_config详解

ssh_config详解

配置“/etc/ssh/ssh_config”文件

“/etc/ssh/ssh_config” 文件是OpenSSH系统范围的配置文件,允许你通过设置不同的选项来改变客户端程序的运行方式。这个文件的每一行包含“关键词-值”的匹配,其中“关键词”是忽略大小写的。下面列出来的是最重要的关键词,用man命令查看帮助页(ssh (1))可以得到详细的列表。

编辑“ssh_config”文件(vi /etc/ssh/ssh_config),添加或改变下面的参数:

# Site-wide defaults for various options
Host *
ForwardAgent no
ForwardX11 no
RhostsAuthentication no
RhostsRSAAuthentication no
RSAAuthentication yes
PasswordAuthentication yes
FallBackToRsh no
UseRsh no
BatchMode no
CheckHostIP yes
StrictHostKeyChecking no
IdentityFile ~/.ssh/identity
Port 22
Cipher blowfish
EscapeChar ~

下面逐行说明上面的选项设置:

Host *
选项“Host”只对能够匹配后面字串的计算机有效。“*”表示所有的计算机。

ForwardAgent no
“ForwardAgent”设置连接是否经过验证代理(如果存在)转发给远程计算机。

ForwardX11 no
“ForwardX11”设置X11连接是否被自动重定向到安全的通道和显示集(DISPLAY set)。

RhostsAuthentication no
“RhostsAuthentication”设置是否使用基于rhosts的安全验证。

RhostsRSAAuthentication no
“RhostsRSAAuthentication”设置是否使用用RSA算法的基于rhosts的安全验证。

RSAAuthentication yes
“RSAAuthentication”设置是否使用RSA算法进行安全验证。

PasswordAuthentication yes
“PasswordAuthentication”设置是否使用口令验证。

FallBackToRsh no
“FallBackToRsh”设置如果用ssh连接出现错误是否自动使用rsh。

UseRsh no
“UseRsh”设置是否在这台计算机上使用“rlogin/rsh”。

BatchMode no
“BatchMode”如果设为“yes”,passphrase/password(交互式输入口令)的提示将被禁止。当不能交互式输入口令的时候,这个选项对脚本文件和批处理任务十分有用。

CheckHostIP yes
“CheckHostIP”设置ssh是否查看连接到服务器的主机的IP地址以防止DNS欺骗。建议设置为“yes”。

StrictHostKeyChecking no
“StrictHostKeyChecking”如果设置成“yes”,ssh就不会自动把计算机的密匙加入“$HOME/.ssh/known_hosts”文件,并且一旦计算机的密匙发生了变化,就拒绝连接。

IdentityFile ~/.ssh/identity
“IdentityFile”设置从哪个文件读取用户的RSA安全验证标识。

Port 22
“Port”设置连接到远程主机的端口。

Cipher blowfish
“Cipher”设置加密用的密码。

EscapeChar ~
“EscapeChar”设置escape字符。

论坛徽章:
0
176 [报告]
发表于 2007-01-13 18:04 |只看该作者

sshd_config详解

sshd_config详解

配置“/etc/ssh/sshd_config”文件

“/etc/ssh/sshd_config”是OpenSSH的配置文件,允许设置选项改变这个daemon的运行。这个文件的每一行包含“关键词-值”的匹配,其中“关键词”是忽略大小写的。下面列出来的是最重要的关键词,用man命令查看帮助页(sshd (8))可以得到详细的列表。

编辑“sshd_config”文件(vi /etc/ssh/sshd_config),加入或改变下面的参数:

# This is ssh server systemwide configuration file.
Port 22
ListenAddress 192.168.1.1
HostKey /etc/ssh/ssh_host_key
ServerKeyBits 1024
LoginGraceTime 600
KeyRegenerationInterval 3600
PermitRootLogin no
IgnoreRhosts yes
IgnoreUserKnownHosts yes
StrictModes yes
X11Forwarding no
PrintMotd yes
SyslogFacility AUTH
LogLevel INFO
RhostsAuthentication no
RhostsRSAAuthentication no
RSAAuthentication yes
PasswordAuthentication yes
PermitEmptyPasswords no
AllowUsers admin

下面逐行说明上面的选项设置:

Port 22
“Port”设置sshd监听的端口号。

ListenAddress 192.168.1.1
“ListenAddress”设置sshd服务器绑定的IP地址。

HostKey /etc/ssh/ssh_host_key

“HostKey”设置包含计算机私人密匙的文件。

ServerKeyBits 1024
“ServerKeyBits”定义服务器密匙的位数。

LoginGraceTime 600
“LoginGraceTime”设置如果用户不能成功登录,在切断连接之前服务器需要等待的时间(以秒为单位)。

KeyRegenerationInterval 3600
“KeyRegenerationInterval”设置在多少秒之后自动重新生成服务器的密匙(如果使用密匙)。重新生成密匙是为了防止用盗用的密匙解密被截获的信息。

PermitRootLogin no
“PermitRootLogin”设置root能不能用ssh登录。这个选项一定不要设成“yes”。

IgnoreRhosts yes
“IgnoreRhosts”设置验证的时候是否使用“rhosts”和“shosts”文件。

IgnoreUserKnownHosts yes
“IgnoreUserKnownHosts”设置ssh daemon是否在进行RhostsRSAAuthentication安全验证的时候忽略用户的“$HOME/.ssh/known_hosts”

StrictModes yes
“StrictModes”设置ssh在接收登录请求之前是否检查用户家目录和rhosts文件的权限和所有权。这通常是必要的,因为新手经常会把自己的目录和文件设成任何人都有写权限。

X11Forwarding no
“X11Forwarding”设置是否允许X11转发。

PrintMotd yes
“PrintMotd”设置sshd是否在用户登录的时候显示“/etc/motd”中的信息。

SyslogFacility AUTH
“SyslogFacility”设置在记录来自sshd的消息的时候,是否给出“facility code”。

LogLevel INFO
“LogLevel”设置记录sshd日志消息的层次。INFO是一个好的选择。查看sshd的man帮助页,已获取更多的信息。

RhostsAuthentication no
“RhostsAuthentication”设置只用rhosts或“/etc/hosts.equiv”进行安全验证是否已经足够了。

RhostsRSAAuthentication no
“RhostsRSA”设置是否允许用rhosts或“/etc/hosts.equiv”加上RSA进行安全验证。

RSAAuthentication yes
“RSAAuthentication”设置是否允许只有RSA安全验证。

PasswordAuthentication yes
“PasswordAuthentication”设置是否允许口令验证。

PermitEmptyPasswords no
“PermitEmptyPasswords”设置是否允许用口令为空的帐号登录。

AllowUsers admin
“AllowUsers”的后面可以跟着任意的数量的用户名的匹配串(patterns)或user@host这样的匹配串,这些字符串用空格隔开。主机名可以是DNS名或IP地址。

论坛徽章:
0
177 [报告]
发表于 2007-01-13 18:07 |只看该作者
使用SFTP代替FTP传输文件
FTP(文件传输协议)是一种使用非常广泛的在网络中传输文件的方式,但是,它也同样存在被网络窃听的危险,因为它也是以明文传送用户认证信息。其实在SSH软件包中,已经包含了一个叫作SFTP(Secure FTP)的安全文件传输子系统,SFTP本身没有单独的守护进程,它必须使用sshd守护进程(端口号默认是22)来完成相应的连接操作,所以从某种意义上来说,SFTP并不像一个服务器程序,而更像是一个客户端程序。SFTP同样是使用加密传输认证信息和传输的数据,所以,使用SFTP是非常安全的。但是,由于这种传输方式使用了加密/解密技术,所以传输效率比普通的FTP要低得多,如果您对网络安全性要求更高时,可以使用SFTP代替FTP。若要开启 SFTP功能可以修改sshd2_config文件的下列内容:
# subsystem-sftp sftp-server
去掉行首的“#”,然后重新启动SSH服务器,这样在进行SSH连接时就可以同时使用SFTP传输文件。

关于客户端设置
以上是对服务器的设置,其实在SSH服务器中已经包含了一些客户端工具(如SSH,SFTP工具)。但是,更多的客户端用户使用Windows系统,下面就对Windows上的客户端系统设置加以说明。
首先从上文给出的网址下载“SSHSecureShellClient-3.2.3.exe”文件并安装。安装完成后,在桌面上会产成两个快捷方式,一个是“SSH Secure Shell Client”,用于远程管理,另一个是“SSH Secure File Transfer Client”,用于和服务器进行文件传输。在工具栏中点击“quick connnect”,输入正确的主机名和用户名,然后在弹出的对话框中输入密码完成登录,即可开始执行命令或者传输文件。在使用SFTP时,默认只能显示用户的宿主目录的内容和非隐藏文件。但是,有时候您可能还要查看其它目录或者隐藏文件,这时只需要在菜单“eidt->setting-> file transfer”的选项中选中“show root directory”和“show hidden file”两个选项即可。

使普通用户仅使用SFTP而没有使用Shell的权限
默认情况下管理员给系统添加的账号将同时具有SFTP和SSH的权限。让普通用户使用shell执行命令也是有很大的安全隐患的,如果能够禁止用户使用shell执行命令而仅使用SFTP传输文件,就能消除这种安全隐患,完全实现FTP的功能,
正如上文所述,SFTP没有单独的守护进程,只能借助于sshd守护进程,所以我们仍然需要使用SSH服务器,要保证sshd守护进程处于运行状态。具体实现方法如下:
首先,在编译安装时,编译中一定要有“--enable-static” 选项。安装成功后,在安装目录下的bin目录中执行下面的命令:
[root@localhost bin]# ls -l ssh-dummy-shell* sftp-server2*
将看到下列输出内容:
-rwxr-xr-x 1 root root 1350417 Apr 28 16:30 sftp-server2
-rwxr-xr-x 1 root root 3566890 Apr 28 16:30 sftp-server2.static
-rwxr-xr-x 1 root root 72388 Apr 28 16:30 ssh-dummy-shell
-rwxr-xr-x 1 root root 1813412 Apr 28 16:30 ssh-dummy-shell.static
其中带“static”后缀名,且比较大的两个文件就是加上“--enable-static”选项后生成的,后面我们将用到这里两个文件。
下面以添加普通账号test为例讲述具体操作步骤。
1.在“/home”目录(或者将要存放普通用户宿主目录的目录)下创建“bin”子目录,并将两个static文件复制到此目录下(复制后改名去掉static后缀),执行如下命令:
[root@localhost bin]# cd /usr/local/ssh3.2/bin
[root@localhost bin]#cp ssh-dummy-shell.static /home/bin/ssh-dummy-shell
[root@localhost bin]# cp sftp-server2.static /home/bin/sftp-server
[root@localhost bin]#chown -R root.root /home/bin
[root@localhost bin]#chmod -R 755 /home/bin
2.添加一个组,使以后所有禁止使用shell的用户都属于这个组,这样便于管理更多的用户:
[root@localhost bin]#groupadd template
3.在添加系统账号时使用如下命令:
[root@localhost root]#useradd -s /bin/ssh-dummy-shell -g template test
[root@localhost root]#passwd test
[root@localhost root]#mkdir /home/test/bin
[root@localhost root]#cd /home/test/bin
[root@localhost bin]#ln /home/bin/ssh-dummy-shell ssh-dummy-shell
[root@localhost bin]#ln /home/bin/sftp-server sftp-server
[root@localhost bin]#chown -R root.root /home/test/bin
[root@localhost bin]#chmod -R 755 /home/test/bin
3.用户添加成功后,还需要修改/etc/ssh2/sshd2_config文件,将下列内容:
#ChRootGroups sftp,guest
改为:
ChRootGroups sftp,guest,template
修改上面这行内容,主要是为了禁止普通用户查看系统的其它目录,把其权限限制在自己的主目录下。重新启动SSH服务器程序,在客户端使用SSH Secure File Transfer Client登录,即使选择显示根目录,普通用户也看不到其它的任何目录,而是把自己的主目录当作根目录。注意,这里使用的是按用户所属组限制,这样可以使包含在template组内的所有用户都可以实现此功能。若您只要限制个别用户的话,可以修改下面的内容:
#ChRootUsers anonymous,ftp,guest

事实证明SSH是一种非常好的网络安全解决方案,但是,目前仍有很多管理员使用Telnet或FTP这种非常不安全的工具,希望尽快转移到SSH上来,以减少网络安全隐患。

来源: http://callof.net/Site/pView.Asp?id=5204

论坛徽章:
0
178 [报告]
发表于 2007-01-14 11:00 |只看该作者

修补贴

在下只是一个新手, 难免很多错误, 欢迎各位更正.

修正80楼错误
备份整个硬盘指令
#dd if=/dev/ad0 of=/dev/ad1

论坛徽章:
0
179 [报告]
发表于 2007-01-14 11:55 |只看该作者
本贴内容均来自网络

转载, 重新制作, 发行时请保留下面的信息:

作者:minok
联系:minok100@126.com
出自:http://bbs.chinaunix.net/

论坛徽章:
0
180 [报告]
发表于 2007-01-14 11:55 |只看该作者
保留
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP