方法一:
一、定义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
yum -y install clamd ← 在线安装 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 ← 赋予脚本可被执行的权限
crontab -e ← 编辑计划任务,添加如下行
00 03 * * * /root/scan.sh ← 添加这一行,让其在每天3点钟执行扫描
四、病毒扫描
[root@sample ~]# clamdscan ← 进行病毒扫描
← 没有发现病毒
[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
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使用的端口。
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
在以前操作中,请注意大小写。
今天在弄vsftpd的时候,犯了一个低级错误。
通过Windows系统的CMD登陆进入vsftpd服务器,上传、下载文件、新建目录都正常,用rm命令删除文件却提示:
550 Remove directory operation failed.
后来看了相关ftp下面的命令,才想起来,ftp命令里删除文件是用del命令,而不是rm命令,删除空目录用rmdir命令。
今天突然发现虚拟机里的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)即可。





