06、自动挂载+超级守护进程+时间同步+tcpwrapper+软硬链接+日志管理
autofs 自动挂载服务
.mkdir /nfs
.vim /etc/auto.master
/nfs /etc/auto.nfs --后面这个文件不存在,自定义的名字
.# vim /etc/auto.nfs
soft - 172.16.2.35:/share/soft
iso - 172.16.2.35:/share/iso
. /etc/init.d/autofs restart --服务只要是开启状态就可以,不用重启
Extended Internet Services Daemon
chkconfig --list |grep xinetd
xinetd based services:
chargen-dgram: off
chargen-stream: off
cvs: off
daytime-dgram: off
daytime-stream: off
discard-dgram: off
discard-stream: off
echo-dgram: off
echo-stream: off
rsync: off
tcpmux-server: off
tftp: on
time-dgram: on
time-stream: on
stand alone --指的非xinetd下的那些服务
super daemon --指的就是xinetd下的那些服务
service rsync --服务名
{
disable = yes --disable等于yes表示此服务关闭
socket_type = stream --tcp的连线机制
wait = no --不等待,可以同时进行大量连线功能
user = root --用root身份启动服务
server = /usr/bin/rsync --定义你的rsync的服务执行文件的位置
server_args = --daemon --服务参数,man rsync可以查到这个参数,表示rsync以守护进程的方式来运行
log_on_failure += USERID --登录错误时,额外记录你的用户id
}
service ssh
{
disable = no
socket_type = stream
protocol = tcp
wait = no
user = root
server = /usr/sbin/sshd
server_args = -i
}
service ssh
{
disable = no
socket_type = stream
protocol = tcp
wait = no
user = root
server = /usr/sbin/sshd
server_args = -i
only_from = 10.1.1.0/24 --允许10.1.1.0/24网段访问
no_access = 10.1.1.104 --拒绝10.1.1.104访问
}
service ssh
{
disable = no
socket_type = stream
protocol = tcp
wait = no
user = root
server = /usr/sbin/sshd
server_args = -i
only_from = 2.2.2.0/24
no_access = 2.2.2.35
access_times = 10:00-14:00
instances = 2
per_source = 1
log_type = file /var/log/xinetd_ssh.log
}
service ssh
{
disable = no
socket_type = stream
protocol = tcp
wait = no
user = root
server = /usr/sbin/sshd
server_args = -i
only_from = 2.2.2.0/24
no_access = 2.2.2.35
access_times = 10:00-14:00
instances = 2
per_source = 1
log_type = file /var/log/xinetd_ssh.log
redirect = 2.2.2.156 22
}
service ssh
{
disable = no
socket_type = stream
protocol = tcp
port = 2222
wait = no
user = root
server = /usr/sbin/sshd
server_args = -i
only_from = 2.2.2.0/24
no_access = 2.2.2.35
access_times = 10:00-14:00
instances = 2
per_source = 1
log_type = file /var/log/xinetd_ssh.log
# redirect = 2.2.2.156 22
}
8 restrict 127.0.0.1 kod nomodify notrap nopeer noquery
14 #restrict 127.0.0.1
18 restrict 172.16.2.0 mask 255.255.255.0 nomodify notrap
# ntpdate 172.16.2.35 --自己同步自己不可以,只能是没有开启ntp的客户端同步开启ntp的服务器
16 Nov 14:24:16 ntpdate[13933]: the NTP socket is in use, exiting
# ntpdate 172.16.2.35 --用其它客户端来同步服务器,大概需要等待5分钟左右才可以同步
22 Sep 11:31:48 ntpdate[2527]: no server suitable for synchronization found
[root@li test]# vim /etc/xinetd.d/time-dgram
disable = no
[root@li test]# vim /etc/xinetd.d/time-stream
disable = no /etc/init.d/xinetd restart
Summary : A security tool which acts as a wrapper for TCP daemons.
Description :
The tcp_wrappers package provides small daemon programs which can
monitor and filter incoming requests for systat, finger, FTP, telnet,
rlogin, rsh, exec, tftp, talk and other network services. Install the tcp_wrappers program if you need a security tool for
filtering incoming network services requests. This version also supports IPv6.
/etc/hosts.allow
/etc/hosts.deny
[root@li test]# which sshd
/usr/sbin/sshd
[root@li test]# ldd /usr/sbin/sshd |grep wrap
libwrap.so.0 => /lib/libwrap.so.0 (0x00d39000) --有此模块就表示支持 # rpm -qf /lib/libwrap.so.0
tcp_wrappers-7.6-40.7.el5
--不是所有的服务都支持,很多软件编译时会有./configure --enable-libwrap来支持tcpwrapper 由两个文件来控制
/etc/hosts.allow
/etc/hosts.deny
访问控制机制为先去匹配/etc/hosts.allow,再去匹配/etc/hosts.deny,如果都没有,则都允许
vim /etc/hosts.deny
sshd: all --拒绝所有
sshd: all EXCEPT 10.1.1.104 --只允许104ssh上来
sshd: all EXCEPT 10.1.1.104 10.1.1.105
sshd: 10.1.1.0/255.255.255.0 EXCEPT 10.1.1.104 --拒绝10.1.1.0网段的人ssh访问,除了104外;注意子网掩码不支持/24写法
sshd:all:spawn echo "`date`" %c %d >> /var/log/tcpwrapperdeny.log --拒绝所有人登录,并把拒绝的时间和IP等信息保存到日志文件
sshd:all:spawn wall %c "login denied" --拒绝所有人登录,只要一登录被拒绝,就发送广播信息
sshd:all EXCEPT 10.1.1.35: spawn wall %c "login denied"
[root@li ~]# ll -i /etc/grub.conf
427497 lrwxrwxrwx 1 root root 22 Feb 27 08:43 /etc/grub.conf -> ../boot/grub/grub.conf
[root@li ~]# ll -i /boot/grub/grub.conf
16083 -rw------- 1 root root 635 Mar 11 10:42 /boot/grub/grub.conf
[root@li ~]# which vi
/bin/vi
[root@li ~]# which vim
/usr/bin/vim
[root@li ~]# mv /bin/vi /bin/vi.bak
[root@li ~]# ln -s /usr/bin/vim /bin/vi --不要写反了
[root@li ~]# ll /bin/vi
lrwxrwxrwx 1 root root 12 Mar 11 14:07 /bin/vi -> /usr/bin/vim
[root@li ~]# rm /bin/vi -rf --删除是删除前面的那个,不是删除后面的;如果删除后面的会造成死链接
[root@li ~]# mv /bin/vi.bak /bin/vi
[root@li test]# mkdir aaa
[root@li test]# ln -s aaa bbb
[root@li test]# ll bbb -d
lrwxrwxrwx 1 root root 3 Apr 21 14:02 bbb -> aaa --目录可以手动做软链接
[root@li ~]# touch 123
[root@li ~]# ln -s 123 /boot/456
[root@li ~]# ll /boot/456
lrwxrwxrwx 1 root root 3 Apr 21 13:48 /boot/456 -> 123 --跨分区的死链接
[root@li ~]# rm /boot/456 -rf
[root@li ~]# ln -s /root/123 /boot/456
[root@li ~]# ll /boot/456
lrwxrwxrwx 1 root root 9 Apr 21 13:49 /boot/456 -> /root/123 --链接时应该写绝对路径
[root@li ~]# ldd /bin/ls
linux-gate.so.1 => (0x00e5e000)
librt.so.1 => /lib/librt.so.1 (0x00792000)
libacl.so.1 => /lib/libacl.so.1 (0x00ae4000)
libselinux.so.1 => /lib/libselinux.so.1 (0x00a0a000)
libc.so.6 => /lib/libc.so.6 (0x004c9000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00640000)
/lib/ld-linux.so.2 (0x004ab000)
libattr.so.1 => /lib/libattr.so.1 (0x00d78000)
libdl.so.2 => /lib/libdl.so.2 (0x0063a000)
libsepol.so.1 => /lib/libsepol.so.1 (0x00a24000)
[root@li test]# ln 3 /boot/4
ln: creating hard link `/boot/4' to `3': Invalid cross-device link
[root@li test]# mkdir aaa
[root@li test]# ln aaa bbb
ln: `aaa': hard link not allowed for directory --不能手动对目录进行硬链接,但是系统还是有一些目录的硬链接。如下面的三对:
[root@li test]# ll -di /var/mail/
196459 drwxrwxr-x 2 root mail 4096 Jul 5 10:45 /var/mail/
[root@li test]# ll -di /var/spool/mail/
196459 drwxrwxr-x 2 root mail 4096 Jul 5 10:45 /var/spool/mail/ [root@li test]# ll -di /etc/httpd/logs/
261891 drwx------ 2 root root 4096 Jul 3 10:54 /etc/httpd/logs/
[root@li test]# ll -di /var/log/httpd/
261891 drwx------ 2 root root 4096 Jul 3 10:54 /var/log/httpd/ [root@li test]# ll -di /etc/init.d/
10672002 drwxr-xr-x 2 root root 4096 Jul 5 11:25 /etc/init.d/
[root@li test]# ll -di /etc/rc.d/init.d/
10672002 drwxr-xr-x 2 root root 4096 Jul 5 11:25 /etc/rc.d/init.d/
/var/log/ --此目录下很多系统日志都存放在此
/var/log/messages --非常重要的日志文件,几乎所有系统发生的重要错误都会记录在此
/var/log/secure --ssh ftp telnet pop3 pam等有关
/var/log/dmesg --开机时核心检测过程中所产生的信息
/var/log/cron --查看时间任务有关的日志
/var/log/wtmp --用last查看,不能直接cat
/var/log/btmp --用lastb查看,不能直接cat
/var/log/lastlog --用lastlog查看
/var/log/boot.log --dns指向的更新会记录在这
/var/log/rpmpkgs --rpm相关
/var/log/maillog --mail相关
/var/log/spooler --news,uucp
/var/log/acpid --高级电源管理
/var/log/yum.log --yum程序相关的日志
auth -- pam产生的日志
authpriv --包括权限,登录相关的信息
cron --时间任务相关的信息,crontab,at
mail --邮件相关的信息
kern --内核产生的信息
uucp --unix to unxi copy 指的是unix系统之间拷贝协议相关的信息
news --新闻组相关的信息
local0 到 local7 --程序自定义的日志设备
mark --syslog服务内部的一些信息,产生一个时间标识
user --用户程序产生的相关信息
debug --调试,产生的日志是最多的一个级别
info --一般信息的日志,最常用
notice --最具有重要性的普通条件的信息
warning或warn --警告级别
err或error --错误级别,阻止某个功能或者模块不能正常工作的信息
crit --严重级别,阻止整个系统或者整个软件不能正常工作的信息
alert --需要马上修改的信息
emerg或panic --内核崩溃等严重错误
none --什么都不记录
. 记录大于等于此等级
.= 只记录等于此等级的信息
.! 不等于此等级,也就是记录此等级之外的信息
# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.* /dev/console --/dev/console指的是一种外接的终端设备,有些封闭主机(没有screen,keyboard,mouse等),可能会需要外接设备连接
# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none /var/log/messages --记录所有日志类型的info级别的信息到/var/log/messages,除了mail,authpriv,cron的信息
# The authpriv file has restricted access.
authpriv.* /var/log/secure --记录authpriv的所有级别的信息到/var/log/secure
# Log all the mail messages in one place.
mail.* /var/log/maillog --记录邮件的所有级别的信息到/var/log/maillog,关于减号-的意思为:因为邮件的信息相比于其他的来说是比较大的,所以是采用异步的方式,先存放在内存里,然后按一定的事件触发,或者到达一定的大小写到磁盘,而不是象其他的日志那样,产生了就马上写到磁盘。 # Log cron stuff
cron.* /var/log/cron --记录时间任务所有级别的信息到/var/log/cron # Everybody gets emergency messages
*.emerg * --记录所有日志设备的emerg信息以wall的方式发送给每个登录到系统的人知道
# Save news errors of level crit and higher in a special file.
uucp,news.crit /var/log/spooler --记录uucp,new的crit信息到/var/log/spooler
# Save boot messages also to boot.log
local7.* /var/log/boot.log
mail.=info /var/log/newmaillog
cron.info;cron.!err /var/log/newcron
# vim /etc/ssh/sshd_config
SyslogFacility local5 --修改成local5,把ssh的日志定义由local5来记录
# /etc/init.d/sshd restart --重启使之生效 # vim /etc/rsyslog.conf
local5.* /var/log/ssh --加这么一句
# /etc/init.d/syslog restart --重启后/var/log/ssh文件被自动创建
验证发现所有的ssh登录有关的信息被记录到了/var/log/ssh
例4:
把71的ssh登录信息记录到35的/var/log/remotessh.log日志文件里
SYSLOGD_OPTIONS="-m 0 -r" --加-r参数
/etc/init.d/syslog restart --重启服务
[root@li ~]# netstat -ntlup |grep sys --加了-r参数后打开了远程日志功能,那么就会多了一个监听端口,为udp的514端口
udp 0 0 0.0.0.0:514 0.0.0.0:* 4252/syslogd
SyslogFacility local5
/etc/init.d/sshd restart
local5.* @10.1.1.35
local5.* /var/log/remotessh.log
/etc/init.d/syslog restart
先在服务器35上
# vim /etc/rsyslog.conf --把下面两行打开,表示监听tcp的514端口,供远程日志连接的
$ModLoad imtcp
$InputTCPServerRun
# /etc/init.d/rsyslog restart 在客户端71上做 vim /etc/ssh/sshd_config
SyslogFacility local5
/etc/init.d/sshd restart vim /etc/rsyslog.conf
local5.* @@10.1.1.35: --rhel6客户端的写法不同了
/etc/init.d/syslog restart 再回到35上做
vim /etc/rsyslog.conf
local5.* /var/log/remotessh.log
/etc/init.d/rsyslog restart
#!/bin/bash
read -p "please input the directory:" dir
find $dir -type l | while read file
do
if [ ! -e $file ]
then
echo "$file is dead link file";
fi
done
#!/bin/bash
read -p "输入一个你要查找死链接的目录:" dir
if [ ! -d $dir ];then
echo "你输入的不是目录或不存在,重试!"
exit 1
fi check_dead_link () {
for i in $1/*
do
[ -h $i -a ! -e $i ] && echo "$i是死链接"
[ -d $i ] && check_dead_link $i
done
} check_dead_link $dir
06、自动挂载+超级守护进程+时间同步+tcpwrapper+软硬链接+日志管理的更多相关文章
- Linux:SAMBA共享、NFS共享、Autofs自动挂载
SAMBA.NFS共享区别 NFS开源文件共享程序:NFS(NetworkFile System)是一个能够将多台Linux的远程主机数据挂载到本地目录的服务,属于轻量级的文件共享服务,不支持Linu ...
- 在Linux上挂载Windows共享文件夹,如何开机自动挂载(mount)?
按照一般的思路,我们先将文件夹挂载上去,命令如下: mkdir /mnt/share_software mount //192.9.206.43/share_software /mnt/share_s ...
- 使用udev实现显示器的热插拔和usb的自动挂载
udev:用来监听硬件设备是否发生改变,并可以给硬件设备命名 ,也可以在硬件发生改变之后执行脚本 使用udev检测显示器是否发生变化,然后执行脚本,解决linux显示器热插拔问题 先补充一点: [ro ...
- 2-5-NFS服务器配置和autofs自动挂载-配置Samba服务器配置现实文件共享
大纲: NFS服务器运行原理 实战配置NFS服务器 配置Samba服务器配置现实文件共享 ----------------------------------------------- 问题: # 怎 ...
- linux mount / umount 命令的基本用法 及 开机自动挂载
格式:mount [-参数] [设备名称] [挂载点] 其中常用的参数有: -a 安装在/etc/fstab文件中类出的所有文件系统. -f 伪装mount,作出检查设备和目录的样子,但并不真正挂载文 ...
- Linux基础知识之挂载详解(mount,umount及开机自动挂载)
Linux基础知识之挂载详解(mount,umount及开机自动挂载) 转载自:http://www.linuxidc.com/Linux/2016-08/134666.htm 挂载概念简述: 根文件 ...
- Linuxautofs自动挂载服务
autofs服务程序是一种Linux系统守护进程,当检测到用户试图访问一个尚未挂载的文件系统时,将自动挂载该文件系统.将信息填入/etc/fstab文件后,系统在每次开机时都自动将其挂载,而autof ...
- 03、磁盘管理+swap分区创建+磁盘配额+自动挂载
磁盘管理 分区标识 一般用4位标识,前两位,磁盘类型,第3位,磁盘编号,第4位,分区编号 如: /dev/sda1 sd 磁盘类型 a 磁盘编号 1 分区编号 [root@s1 ...
- Xinetd超级守护进程
Xinetd超级守护进程 00.什么是xinetd服务 xinetd(extended Internet services daemon), 是新一代网络守护进程服务程序, 又叫超级守护进程. 经常用 ...
随机推荐
- HTML中,input元素的 Disabled属性 所产生的后端无法接收数据的问题
背景 今天从前端提交 form表单 数据时,发现 设置 Disabled 的 input 元素的字段数据在后端无法接收到 原因 查阅资料(来自W3school): disabled 属性规定应该禁用 ...
- html 单元格合并
<table border="1" style={{margin:200}}> <tbody> <tr> <th colspan=&quo ...
- nginx使用多端口监听多个服务
###### nginx监听多个端口并转发给不同的服务 ### 第一个监听: upstream odoo { server localhost:; } upstream odoochat{ serve ...
- NLP之分词
不同分词工具原理解析 对各种分词工具的介绍,具体参考: http://www.cnblogs.com/en-heng/p/6234006.html 1) jieba 具体参考: https://blo ...
- windwos文件句柄数限制
1.修改注册表,位置如下: HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Windows 2.设置 1.GDIProc ...
- [LeetCode] 76. Minimum Window Substring 最小窗口子串
Given a string S and a string T, find the minimum window in S which will contain all the characters ...
- 阿里云等云端服务器VPS改造为ROS-Routeros,最大化利用云端硬盘
因为ROS官方提供的CHR镜像是用16G版本做出来的,所以我们用dd的方法做出来的ROS,空间都是16G. 如果你的云端是40G空间或者更多呢,也只用了16G空间,是不是很浪费. 我今天看到一篇大神写 ...
- PCA:主成分分析
PCA的概念: 主要思想是将n维特征映射到k维上,这k维是全新的正交特征,这k维特征被称为主成分,在原数据的基础上重新构造出来k维.就是从原始的空间顺序的找出一组相互正交的坐标轴,新坐标轴的选择和数据 ...
- python 做词云图
#导入需要模块 import jieba import numpy as np import matplotlib.pyplot as plt from PIL import Image from w ...
- Python 学习:常用函数整理
整理Python中常用的函数 一,把字符串形式的list转换为list 使用ast模块中的literal_eval函数来实现,把字符串形式的list转换为Python的基础类型list from as ...