服务器维护,服务器代维,安全设置,漏洞扫描,入侵检测服务

运维之家

 找回密码
 注册
搜索
查看: 4913|回复: 0

linux 常见错误解决方法(转)

[复制链接]
dirtysea 发表于 2009-8-9 18:00:39 | 显示全部楼层 |阅读模式
10、pam
11、拒绝ssh登录(用户)
a./etc/ssh/sshd_config
denyusers user
b.pam 中/etc/security/access.conf
/etc/pam.d/sshd

¥¥¥¥¥¥¥¥¥¥¥¥
  一、MBR错误。   
¥¥¥¥¥¥¥¥¥¥¥¥¥
二  grub.conf
三、/etc/inittab
¥¥¥¥¥¥¥¥¥¥¥¥¥
四、
mount /sbin/init /bin/bash   文件丢失或被替换
¥¥¥¥¥¥¥¥¥¥¥¥¥
五。xwindow错误
一般来说与/etc/X11/XF86config文件有关,考试中不可能涉及硬盘问题。
运行redhat-config-xfree86一般都能解决,可能发生的问题较多,普通点的就是刷新率,显
示模式如800x600等。
还有
空间满和配置文件无!!
X字体服务(xfs)是否运行
¥¥¥¥¥¥¥¥¥¥¥¥¥
六、
root不能正常登录

********密码
(一)出现Login incorrect 多半与密码相关
1、的确是密码错误 单用户模式修改
2、root用户被锁  单用户模式 usermod -U root 即可
3、没有root用户,即没有uid为0的用户
4、/etc/securetty文件中没有tty*(*表示1,2,3,4等)
5。密码过期和锁定
常用的两种让 帐户无法登陆的方法
a.
shadow文件的 密码这一位  前面加!!   表示帐户被锁 登陆时的提示是 密码error,logs里提示是 认证失败
root:!!$1$3njamFCM$y6axVvkvvw7eS04bfOprz/:12908:0:99999:7:::
解决方法:把!!去掉
b.
shadow 文件的最后一位 也就是  从1970。1。1号开始 多少天帐号失效 这一位 加具体时间
root:$1$3njamFCM$y6axVvkvvw7eS04bfOprz/:12908:0:99999:7::1:
如上,表示 1970。1。1后 1 天失效
解决方法: 把1 去掉

d./etc/securitty 定义了
root可安全登录的终端
e.没用root用户,uid=0 用户不存在
2、user不可登录
同上a. b . c.
d .存在/etc/nologin空文件
e.passwd文件中没有shell或被替换
f. /etc/bash_profile
g. .bash_profile 中有exit,logout
3、root user都不可登录, /bin/bash被替换或删除
4、检查pam, /etc/security/access.conf , /etc/pam.d/system-auth,
用authconfig清除设置

无法修改密码,报unable to lock password file. 错误
linux修改不了密码(包括root帐号),也不能建立新帐号,提示unable to lock password file. 修改passwd, shadow的属性结果还是一样
  答:出现该信息,说明上次更改密码的程序(passwd)没有正常退出, 或者现在有另外一个程序正在使用/etc/passwd文件。可以到/etc下查看相关的*lock*文件, 以及passwd文件的属性,将相关的lock文件删除,然后再修改密码即可。
  

PAM相关*******
(二)输入用户名和密码后,只见屏幕一闪,,那多半与authconfig、pam有关了
1、三轮车夫同志遇到的。authconfig时,选了ldap认证,后来ldap服务器的地址变了后,
就无法登录。
   解决办法:运行 authconfig取消该选项。
2、/etc/pam.d/system-auth中添加了
   account required /lib/security/$ISA/pam_access.so
   或其他类似的pam模式限制,如pam_listfile.so、pam_time.so等。
  解决办法同上,运行authconfig后会自动删掉。
3、/etc/pam.d/login中添加了
   account required /lib/security/$ISA/pam_access.so
   或其他类似的pam模式限制,如pam_listfile.so、pam_time.so等。
  解决办法:只有手工去查看login文件,运行authconfig后不会自动取消。
4、/etc/pam.d/  目录中的system-auth 或login中的模块文件名有误。
  模块文件名错误同样会使系统无法登录。
  建议发生无法登录的情况时,到单用户或rescue模式,首先查看/var/log/secure 和
message文件。

¥¥¥¥¥¥¥¥¥¥¥¥¥
七、
服务的控制:
(一)网络配置错误
      ip addr netmask route gateway 大不了加上tc iptables ipchains 以及相关的配置文件
(二)DNS解析错误
      大多在/etc/host.conf /etc/resolve.conf  /etc/hosts这些文件有关
(三)xwindow的桌面环境及主要的一次配置文件.xinitrc、XF86Config、/etc/X11/Xxxx目
录下面的
(四)磁盘分区,文件系统,swap分区相关
    (五)诊断和修复其他daemon错误(就是各种网络服务啦),
1、HTTP/HTTPS
   httpd -t 测试配置文件
2、SMB
   testparm 测试配置文件
3、NFS
   showmount -e localhost 看自己是否正常提供了exports
   rcpinfo -p localhost   看portmap 是否正常
4、FTP
   AS3目前自带vsftpd,配置非常简单
5、Web proxy
   AS3目前自带squid,如果只是要配置一个简单的带认证的web proxy,根据conf文件
修改非常简单
6、SMTP
   默认sendmail、也可使用postfix(网易就是用的这个)
7、IMAP, IMAPS, and POP3
   要简单使用,几乎不用配置。
8、SSH
   /etc/ssh/sshd_config,几乎每天都要用的东西
9、DNS
   named-checkconf   named-checkzone检查配置文件
   确实找不到问题所在,rpm -ivh --force software.2.x.x.x.rpm
八、一道限制telnet 访问的题目
方法有:
add the following line to the /etc/xinetd.d/telnet configuration file:
no_access = 127.0.0.1

/etc/hosts.deny file in a text editor. Add the following line:
in.telnetd : ALL

/sbin/iptables -A INPUT -s 127.0.0.1 -p tcp --dport 23 -j DROP

九:关于启动过程中出错的补充
(一)、mbr损坏或丢失. 进入RESCUE模式,grub-install
linux rescure
grub-install /dev/hda?
(二)、启动时所需的配置文件不正确
(要对文件的内容与格式熟悉)看看"大坏羊"的贴子
Kernel panic : no init found,Try passing init = option to kernel
/boot/grub/grub.conf *************************************************
grub.conf
grub.conf丢失(只能用rescue模式)

如果出错
grub的一般情况
root(hdx,x)错误和 根分区(/分区)即root=/dev/xxx不对
记root(hdx,x) 是内核保存位置即 /boot分区的磁盘。这里写法要注意
root=/dev/xxx 是/分区位置
1、如果没有找到内核(vmlinuz-x.x.x文件),
  出现File not found
    Press any key to continue....
  说明root(hdx,x)错误,或内核文件名不对
2、如果找到内核后,运行一会,
  出现kernel Panic:Not init Found,
  一般来说是没有找到根分区(/分区)即root=/dev/xxx不对
3、如果找到内核后,运行一会,
  出现Kernel panic: VFS: Unable to mount root fs on ...,
  一般来说可能忘了加上initrd /initrd-2.4.21-4.EL.img(大多情况发生在使用scsi硬盘)
4、总的来说grub.conf里面必须存在的就几行。
#more grub.conf
title linux
root (hd0,1)                                        #/boot分区所在位置
kernel /vmlinuz-2.4.21-4.EL ro root=/dev/TEST/root #内核和根分区(/分区)位置
(根分区可能是LVM和raid,而不仅是hdx和sdx)
initrd /initrd-2.4.21-4.EL.img

方法:
root (hd0,1)
ro root=/dev/TEST/root 要会写
如果丢失 需要用rescue模式写这个文件,至少需要title  root   kernel initrd四句
**************************************************

/etc/inittab
**************************************************
方法:如果不大明白//etc/inittab的格式,强制重装initscripts的rpm包即可
一般来说就是inittab文件丢失或者有错误。
方法:如果丢失那就到rescue模式下重新安装,包名initscripts(如果遇到系统有inittab文件要你恢复出来

如果出错,可以到单用户模式下,修改

注意:
如果不是在rescue模式,修改fstab和inittab文件时出来Read-only file system咋办?重新装载成读
写模式
mount -o remount,rw /dev/sdax /
*******************************************************
/etc/fstab  
可以不需要其他方法 ,当出现repaire filesystem时候,输入密码,mount -o remount defaults,rw /
*******************************************************
1。启动rescure模式
2。用fdisk -l看磁盘情况。用e2label /dev/hda?看具体卷标
3。mkdir /mnt/sysimage
4。把所有分区都mount到该目录下。用man fstab看具体写法
5。在/etc下创建 fstab文件。
重新启动。
*******************************************************

(三)、启动系统时,所用的文件或目录丢失
如:mount ,bash,inittab,init ,/initrd ,/proc
1.mount,bash被替换或删除。 进入RESCUE模式,网络重新安装mount,bash包
mount /sbin/init /bin/bash   文件丢失或被替换
如:
在系统启动的时候,提示分区无法加载!
经检查,发现/etc/fstab的信息是正确的!
分析,可能是/bin/mount 命令被替换!
问,现在如何进行系统的修复!

进入linux rescue 模式:
rpm -Vf --root /mnt/sysimage /bin/mount
你会发现有问题!
rpm -qf --root /mnt/sysimage /bin/mount
查找该文件属于哪个RPM安装包
rpm -ivh --force --root /mnt/sysimage /mnt/source/Redhat/RPMS/packagename.rpm
sync
sync
sync
exit

2./sbin/init 丢失或替换。此文件在SysVinit*包内,此包还包括如下文件:/sbin
halt,poweroff,init,runlevel,reboot,shutdown等
init丢失时,(a)、直接启动时会进入bash2.05#只读shell
(b)、用单用户进入如下提示:
s :s no such file or directory
kernel panic : Attempted to kill init
       修复如mount的修复
3.initscripts*包
启动的相关文件:/etc/inittab,/etc/rc.d,/etc/rc.d/rc,rc.sysinit,
/etc/sysconfig/* ,/etc/sysclt.conf, /sbin/ifup,/sbin/ifdown
/sbin/service
# inittab丢失: INIT:no inittab file found.
Enter runlevel:
#/etc/rc.d ,/etc/rc.d/rc 丢失:
用reboot,shutdown,init 6 命令重启时有如下明显提示:
INIT : can not execute "/etc/rc.d/rc"
INIT: no more processes left in this runlevel
按电源重启系统,可以到达login界面:
Kernel 2.4.21-15.EL on an i686
( none ) login :
可以登录,但会提示:
modprobe : modprobe : Can't locate module Char-major-10-224
login(PAM-unix)[22] Session ipened for user root by (uid=0)
-bash: Command not found
此时没有网络,不能修复,主要提示在重启的时候,进入rescue模式,
修复后可正常使用,/etc/rc.d丢失,重新安装initscripts*包,登录时
仍会有提示,但常使用。
#/etc/rc/rc.sysinit 为系统启动时所用的第一个脚本,若丢失
系统启动时:
INIT : can't execute /etc/rc.d/tc.sysinit not found
及其它提示
#/sbin/ifup,/sbin/ifdown 如果丢失,网络将无法启动。
#/sbin/service 若丢失或被替换,任何服务无法启动。
        需要rescue修复。
4. /initrd 目录丢失,启动时有如下提示:
pivotroot: pivotroot (/sysroot,/sysroot/initrd) failed: 2
umount /initrd/proc failed : 2
Freeing unused kernel memory : 164k freed
Kernel panic : no init found,Try passing init = option to kernel
进入rescue模式,建立/initrd 目录即可    需要rescue修复。
(6)Debug Exercise IV
In this exercise, you'll be practicing with Telnet. The service can be on or off by default. It may be blocked by a firewall. Service may be denied through the /etc/xinetd.d/telnet configuration file or through /etc/hosts.deny. Ideally, you'll be able to check your work through another computer on a LAN.
1.Start Red Hat Linux. Check for the installation of the telnet package with the rpm -q telnet command. Install the telnet RPM if required.
2.Check your configuration for a firewall with the /sbin/service iptables status command.
3.If there are iptables rules active on your system, you may want to back them up with the /sbin/iptables-save > filename command.
4.If you have iptables rules, flush them with the /sbin/iptables -F command.
5.Check your /etc/hosts.allow and /etc/hosts.deny files. If there are rules related to in.telnetd or ALL services in either file, comment them out.
6.Check the default status of Telnet with the /sbin/chkconfig --list telnet command. The response should be off or on. Use chkconfig to turn Telnet on if required.
7.Check the /etc/xinetd.d/telnet configuration file. If there are only_from or no_access directives in this file, comment them out.
8.Now you should be able to connect to Telnet. Try it from the local computer with the telnet localhost command. You should be able to log in with a local user name and password. Log out of Telnet.
9.Repeat the telnet access request from a remote computer. Use the name or the IP address of the Telnet server. Log out of Telnet.
10.On the Telnet server, add the following line to the /etc/xinetd.d/telnet configuration file:
no_access = 127.0.0.1
11.From the computer with the Telnet server, try the telnet localhost command. What happens? Is a successful login through Telnet unexpected?
12.Run the /sbin/service xinetd reload command. Repeat step 11. What happens now? If possible, try to use the telnet command to connect to the Telnet server from a different computer on your LAN. Can you connect?
13.Restore the original /etc/xinetd.d/telnet configuration file and run /sbin/service xinetd reload command again.
14.Open the /etc/hosts.deny file in a text editor. Add the following line:
in.telnetd : ALL
15.Repeat step 11. What happens now? Try this again from another computer on your LAN.
16.Restore the original /etc/hosts.deny file.
17.Now try to set up a firewall to block yourself from accessing Telnet on the local computer.
18.Add the following iptables chain to your firewall (the TCP/IP port for Telnet is 23. You can look up the port you need in /etc/services):
/sbin/iptables -A INPUT -s 127.0.0.1 -p tcp --dport 23 -j DROP
19.Verify that your computer accepted this new rule with the iptables -L command. You should see that packets destined for Telnet are to be dropped.
20.Repeat step 11. What happens now? Try to log in via Telnet again from another computer on your LAN.
21.Note how the response is different when you block access through a firewall and through a file such as /etc/hosts.deny.
22.Restore your original firewall. Flush the rule that you created with the /sbin/iptables -F command. Then restore the old rules if required with the /sbin/iptables-restore < filename command.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|手机版|Archiver|运维之家

GMT+8, 2024-3-29 20:49 , Processed in 0.087376 second(s), 14 queries .

Powered by Dirtysea

© 2008-2020 Dirtysea.com.

快速回复 返回顶部 返回列表