10月22

方法一:
一、定义yum的非官方库

在服务器构建的过程中,我们将要用到的一些工具不存在于CentOS中yum的官方库中,所以需要定义yum的非官方库文件,让一些必需的工具通过yum也能够安装。

[root@sample ~]# vi /etc/yum.repos.d/dag.repo  ← 建立dag.repo,定义非官方库
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
enabled=1


[root@sample ~]# rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt  ← 导入非官方库的GPG

附:
在使用yum进行install时,经常会出现下面的错误:
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 1aa78495
warning: livna-release-7.rpm: Header V3 DSA signature: NOKEY, key ID a109b1ec

导致安装不能进行。
解决方法如下:
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*

二、安装Clam AntiVirus
[root@sample ~]# yum -y install clamd  ← 在线安装 Clam AntiVirus
Setting up Install Process
Setting up repositories
dag 100% |=========================| 1.1 kB 00:00
update 100% |=========================| 951 B 00:00
base 100% |=========================| 1.1 kB 00:00
addons 100% |=========================| 951 B 00:00
extras 100% |=========================| 1.1 kB 00:00
Reading repository metadata in from local files
primary.xml.gz 100% |=========================| 1.6 MB 00:08
dag : ################################################## 4610/4610
Added 4610 new packages, deleted 0 old in 94.91 seconds
primary.xml.gz 100% |=========================| 103 kB 00:05
update : ################################################## 256/256
Added 56 new packages, deleted 0 old in 4.25 seconds
Reducing Dag RPM Repository for Red Hat Enterprise Linux to included packages only
Finished
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for clamd to pack into transaction set.
clamd-0.88.4-1.el4.rf.i38 100% |=========================| 5.3 kB 00:00
---> Package clamd.i386 0:0.88.4-1.el4.rf set to be updated
--> Running transaction check
--> Processing Dependency: clamav = 0.88.4-1.el4.rf for package: clamd
--> Processing Dependency: libclamav.so.1 for package: clamd
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for clamav to pack into transaction set.
clamav-0.88.4-1.el4.rf.i3 100% |=========================| 8.1 kB 00:00
---> Package clamav.i386 0:0.88.4-1.el4.rf set to be updated
--> Running transaction check
--> Processing Dependency: clamav-db = 0.88.4-1.el4.rf for package: clamav
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for clamav-db to pack into transaction set.
clamav-db-0.88.4-1.el4.rf 100% |=========================| 3.2 kB 00:00
---> Package clamav-db.i386 0:0.88.4-1.el4.rf set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
clamd i386 0.88.4-1.el4.rf dag 64 k
Installing for dependencies:
clamav i386 0.88.4-1.el4.rf dag 724 k
clamav-db i386 0.88.4-1.el4.rf dag 5.6 M

Transaction Summary
=============================================================================
Install 3 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 6.4 M
Downloading Packages:
(1/3): clamd-0.88.4-1.el4 100% |=========================| 64 kB 00:01
(2/3): clamav-0.88.4-1.el 100% |=========================| 724 kB 00:04
(3/3): clamav-db-0.88.4-1 100% |=========================| 5.6 MB 00:25
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: clamav-db ######################### [1/3]
Installing: clamav ######################### [2/3]
Installing: clamd ######################### [3/3]

Installed: clamd.i386 0:0.88.4-1.el4.rf
Dependency Installed: clamav.i386 0:0.88.4-1.el4.rf clamav-db.i386 0:0.88.4-1.el4.rf
Complete!

若出现以上红色部分,即表示Clam AntiVirus安装完成!

三、配置Clam AntiVirus

1、Clam AntiVirus的使用者配置:
[root@sample ~]# vi /etc/clamd.conf  ← 修改clamd的配置文件
ArchiveBlockMax ← 找到这一行,在行首加上“#”(不把大容量的压缩文件看作被感染病毒的文件)
#ArchiveBlockMax ← 变为此状态

User clamav  ← 找到这一行,在行首加上“#”(不允许一般用户控制)
#User clamav  ← 变为此状态

2、设置Clam AntiVirus开机随系统自启动:
[root@sample ~]# chkconfig clamd on

3、更新Clam AntiVirus的病毒库
[root@sample ~]# freshclam
ClamAV update process started at Fri Aug 25 18:39:26 2006
Downloading main.cvd [*]
main.cvd updated (version: 40, sigs: 64138, f-level: 8, builder: tkojm)
Downloading daily.cvd [*]
daily.cvd updated (version: 1728, sigs: 2565, f-level: 8, builder: ccordes)
Database updated (66703 signatures) from db.cn.clamav.net (IP: 58.221.253.171)
Clamd successfully notified about the update.

4、让Clam AntiVirus定时运行:
[root@sample ~]# vi scan.sh  ← 建立自动扫描脚本,如下:
#!/bin/bash
PATH=/usr/bin:/bin
CLAMSCANTMP=`mktemp`
clamdscan --recursive --remove / > $CLAMSCANTMP
[ ! -z "$(grep FOUND$ $CLAMSCANTMP)" ] && \
grep FOUND $CLAMSCANTMP | mail -s "Virus Found in `hostname`" root
rm -f $CLAMSCANTMP


[root@sample ~]#chmod 700 scan.sh ← 赋予脚本可被执行的权限

[root@sample ~]#crontab -e ← 编辑计划任务,添加如下行
00 03 * * * /root/scan.sh ← 添加这一行,让其在每天3点钟执行扫描

四、病毒扫描

[root@sample ~]# clamdscan  ← 进行病毒扫描
/root: OK ----------- SCAN SUMMARY -----------
Infected files: 0
  ← 没有发现病毒
Time: 5.074 sec (0 m 5 s)

[root@sample ~]# clamdscan --remove  ← 再次进行病毒扫描,并附加删除选项

方法二:
#wget -c http://jaist.dl.sourceforge.net/sourceforge/clamav/clamav-0.94.2.tar.gz

#tar -zxvf clamav-0.94.2.tar.gz

#cd clamav-0.94.2.tar.gz

#groupadd clamav

#useradd -g clamav -s /sbinlogin -c "Clam Antivirus" clamav

# ./configure --sysconfdir=/etc

#make

#su -c "make install"


 修改配置文件

1  使用编辑器修改 /etc/clamd.conf
#vi /etc/clamd.conf

  在 Example 前面加 #

2.
#vi /etc/freshclam.conf
  在 Example 前面加 #

把Checks 从 "24" 改为 "6",并去掉前面的#

这样是每6小时更新一次病毒码。

3.运行clamd守护进程:
/usr/local/sbin/clamd


4.测试

clamdscan -文件及目录的扫毒
扫描整个目录
#/usr/local/bin/clamscan  -r /home
#/usr/local/bin/clamscan  -r /

#/usr/local/bin/clamscan  -r /usr/share/doc/clamav*

更新命令
#/usr/local/bin/freshclamd

5.设置设置clamav随服务器开机自动启动


#touch /etc/init.d/autoclamav

#vi /etc/init.d/autoclamav

内容如下:

echo "now the clamav will be started automaticly"

/usr/local/sbin/clamd

echo "clamav start has be done"

#chmod 777 /etc/init.d/autoclamav

10月14

PSCP是putty 安全复制客户端,使用SSH,可以很方便地在windows 系统传输文件到Linux 系统中。
只需输入命令就可以将windows下的文件传输到Linux系统的磁盘中:

C:\>pscp.exe
PuTTY Secure Copy client
Release 0.60
Usage: pscp [options] [user@]host:source target
pscp [options] source [source...] [user@]host:target
pscp [options] -ls [user@]host:filespec
Options:
-V        print version information and exit
-pgpfp    print PGP key fingerprints and exit
-p        preserve file attributes
-q        quiet, don't show statistics
-r        copy directories recursively
-v        show verbose messages
-load sessname  Load settings from saved session
-P port   connect to specified port
-l user   connect with specified username
-pw passw login with specified password
-1 -2     force use of particular SSH protocol version
-4 -6     force use of IPv4 or IPv6
-C        enable compression
-i key    private key file for authentication
-noagent  disable use of Pageant
-agent    enable use of Pageant
-batch    disable all interactive prompts
-unsafe   allow server-side wildcards (DANGEROUS)
-sftp     force use of SFTP protocol
-scp      force use of SCP protocol


例如:
C:\>pscp.exe c:\pam_mysql.-0.7rc1.tar root@192.168.80.198:/root/Install  //将本地c:\pam_mysql.-0.7rc1.tar文件传输到192.168.80.198主机的/root/Install目录下

The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 1024 26:e3:66:c6:b1:e0:60:50:9a:5a:1a:e1:dd:fd:d2:53
If you trust this host, enter "y" to add the key to
PuTTY's cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n) y
root@192.168.80.198's password:
pam_mysql.-0.7rc1.tar           | 327 kB | 327.7 kB/s | ETA: 00:00:00 | 100%

第一次在本地使用会提示是否保存SSH Key,选择Y保存即可。

C:\>pscp.exe -P 2202 pam_mysql.-0.7rc1.tar root@192.168.80.198:/root/Install

-P参数指定SSH使用的端口。

10月12

1、关闭Mysql:如果 MySQL正在运行,首先用下面的命令杀掉MySQL进程:
[root@localhost root]#killall -TERM mysqld

2、再以后面的方法启动 MySQL进程:/var/bin/safe_mysqld --skip-grant-tables & (注:新版本有的是mysqld_safe命令)
(提示:如果找不到safe_mysqld命令,可以用find -name safe_mysqld 来查找此命令所在的目录,基本上都是在/var/bin目录下面)

3、可以不需要密码就进入MySQL了。

然后执行以下命令:(具体这些命令是做什么相信大家都可以看的懂,也就不多解释了!)

mysql>use mysql
mysql>UPDATE user SET password=password("新密码") WHERE user="root";
mysql>flush privileges;


4、重新杀掉 MySQL 进程,再用正常方法启动 MySQL:
[root@localhost root]#killall -TERM mysqld
[root@localhost root]#service mysqld restart

在以前操作中,请注意大小写。

10月9

今天在弄vsftpd的时候,犯了一个低级错误。

通过Windows系统的CMD登陆进入vsftpd服务器,上传、下载文件、新建目录都正常,用rm命令删除文件却提示:
550 Remove directory operation failed.

后来看了相关ftp下面的命令,才想起来,ftp命令里删除文件是用del命令,而不是rm命令,删除空目录用rmdir命令。

10月6

今天突然发现虚拟机里的Linux登陆很慢,分别用F-Secure SSH Client和putty里的ssh,在输入帐号和密码以后,差不多要等半分钟以后才出现终端窗口。

后在网上发现一种方法,经测试有效:

编辑/etc/ssh/sshd_config文件,在文件末尾加上:UseDns no

或者

直接修改/etc/ssh/sshd_config文件,将里面的
#UseDNS yes
修改为:
UseDNS no

然后保存退出,重启sshd服务(service sshd restart)即可。

Tags: , , , ,
分页: 24/31 第一页 上页 19 20 21 22 23 24 25 26 27 28 下页 最后页 [ 显示模式: 摘要 | 列表 ]