xshell鏈接Linux(centos6.8)失敗的解決方法

注意:本人使用的是Centos6.8版本。 Centos7以上版本linux命令會又不同的地方。linux

啓動xshell終端進行鏈接服務器:使用命令:ssh + ip地址或是手動使用可視化操做窗口操做,shell

出現問題1 :Could not connect to '10.23.57.227' (port 22)centos

一:防火牆開啓關閉:服務器

1. 永久性生效網絡

開啓:chkconfig iptables onssh

關閉:chkconfig iptables offoop

2. 即時生效,重啓後失效spa

開啓:service iptables startrest

關閉:service iptables stopcode

二:ssh-server服務器開啓關閉:

開啓ssh服務:service sshd start

關閉ssh服務:service sshd stop

重啓ssh服務:servcie sshd restart

SSH服務開機自動啓動:chkconfigsshd on

取消開機自啓動:chkconfig sshd off

開啓服務後,檢查服務狀態:service sshd status

總結:防火牆和ssh服務命令幾乎同樣。

三:ping + ip的時候出現異常connect 網絡不可達

使用ifconfig 發現找不到ip地址了,也不知道什麼緣由,就手動輸入命令設置了一個ip:

[root@localhost 桌面]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:C2:1B:05  
          inet6 addr: fe80::20c:29ff:fec2:1b05/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:960 errors:0 dropped:0 overruns:0 frame:0
          TX packets:739 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:725542 (708.5 KiB)  TX bytes:71499 (69.8 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:812 errors:0 dropped:0 overruns:0 frame:0
          TX packets:812 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:79634 (77.7 KiB)  TX bytes:79634 (77.7 KiB)

命令爲:

ifconfig eth0 10.23.57.227 netmask 255.255.255.0

再次ifconfig獲得:

[root@localhost 桌面]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:C2:1B:05  
          inet addr:10.23.57.227  Bcast:10.23.57.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fec2:1b05/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:960 errors:0 dropped:0 overruns:0 frame:0
          TX packets:739 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:725542 (708.5 KiB)  TX bytes:71499 (69.8 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:812 errors:0 dropped:0 overruns:0 frame:0
          TX packets:812 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 

 能夠ping通。。。

 四:如何卸載centos系統自帶的ssh

yum remove openssh-clients
yum remove openssh-server

總結:我發現上面全部的端口號佔有問題。防火牆問題,都沒有錯誤的時候以及從新卸載安裝ssh服務,依然不能爭取的解決問題,而後本身又從新安裝了一個虛擬主機,
輸入ifcong,發現其ip地址是隨機分配的一個ip地址,可是在一個網段,而 我當時在第一個虛擬主機設置的ip地址是本身手動設置的並且與我本地window主機鏈接網絡
的ip【
10.23.57.227 】地址同樣,不能同樣,因而修改成226成功訪問,,真是蛋疼啊。。。本身給本身挖了個大坑,不過同時溫故而知新,更加熟悉linux相關知識。
相關文章
相關標籤/搜索