遠程鏈接工具是:Xmanager Enterprise 5-->Xshelllinux
linux 發行版本是:CentOS-6.3-x86_64shell
問題:ssh一直均可以遠程鏈接上linux,一段時間後忽然ssh使用本來的IP鏈接不上linux,發生這種狀況時的解決辦法網絡
1.查看網絡配置文件中的IP有沒有改變。ssh
先查看IPADDR有沒有改變,要是沒有被改變,那麼繼續步驟2;要是發生了改變則將IPADDR改爲以前的,而後進行步驟2。tcp
[root@fanycb ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE="eth0" BOOTPROTO=none NM_CONTROLLED="yes" ONBOOT="yes" TYPE="Ethernet" UUID="e57636db-84f8-4c15-af74-97d44a107fa2" HWADDR=00:0C:29:14:5A:57 IPADDR=192.168.1.100 PREFIX=24 GATEWAY=192.168.1.1 DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no NAME="System eth0" [root@fanycb ~]#
2.檢查sshd服務的狀態以及端口是否正常。工具
[root@fanycb ~]# netstat -nlp | grep :22 tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2896/sshd tcp 0 0 :::22 :::* LISTEN 2896/sshd [root@fanycb ~]#
[root@fanycb ~]# /etc/init.d/sshd restart
中止 sshd: [肯定] 正在啓動 sshd: [肯定] [root@fanycb ~]#
3.檢查防火牆是否開啓。ui
若是防火牆是關閉的,則進行步驟4;若是防火牆沒有關閉,則 永久性的關閉它,而後進行步驟4。this
[root@fanycb ~]# chkconfig iptables off <====永久關閉防火牆 [root@fanycb ~]# /etc/init.d/iptables status <====而後確認一下是否關閉了 iptables:未運行防火牆 [root@fanycb ~]#
4.這點也是很重要的,那就是,檢查SELinux是否開啓。spa
查看系統SELinux目前的狀態rest
[root@fanycb ~]# getenforce
Disabled <====這是我係統上SELinux的狀態,這是關閉的 [root@fanycb ~]#
若是結果也是"disabled",那麼一切的檢查就ok了,那就能夠鏈接了
可若是結果是"Enforcing"活着"permissive",說明系統上的SELinux是開啓的,須要將它關閉。由於SELinux的開啓與關閉和兩個重要的配置文件有關,分別是/etc/selinux/config和/boot/grub/menu.lst,因此要關閉SELinux就須要修改這兩個文件,方法以下所示:
[root@fanycb ~]# cat /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. #SELINUX=enforcing SELINUX=disabled <====將=號後改成disabled # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. SELINUXTYPE=targeted
[root@fanycb ~]# cat /boot/grub/menu.lst
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/sda5
# initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-279.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-279.el6.x86_64 ro root=UUID=edc1b124-6bc5-4dbe-b2d4-88805da96d4d rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=128M LANG=zh_CN.UTF-8 rd_NO_LVM rd_NO_DM rhg
b quiet selinux=0 <====seliux=0 是添加上去的
initrd /initramfs-2.6.32-279.el6.x86_64.img
[root@fanycb ~]#
好了,全部工做都已經作完啦,如今就能夠盡情的鏈接啦。使用愉快 ^_^