zoukankan      html  css  js  c++  java
  • ssh遇到port 22:No route to host问题的解决方法

    一 iptables 问题

    1.没有安装,可以先安装 
    yum install iptables

    2.防火墙的开启与关闭 
    即时生效,重启失效 
    service iptables start(开启) 
    service iptables stop(关闭) 
    service iptables restart(重启) 
    永久生效 
    chkconfig iptables on(开启) 
    chkconfig iptables off(关闭)

    查看防火墙运行状态 
    service iptables status

    3.清除防火墙规则 
    iptables -F 
    iptables -X 
    iptables -Z

    4.开放端口22 
    iptables -A INPUT -p tcp –dport 22 -j ACCEPT 
    iptables -A OUTPUT -p tcp –sport 22 -j ACCEPT

    5保存设置 
    /etc/rc.d/init.d/iptables save

    service iptables restart(重启一下)

    iptables操作最后都记得要执行一下此步骤(如3, 4)

    6 查看防火墙规则 
    iptables -nL

    7 直接向防火墙?件中添加规则 
    vi /etc/iptables.test.rules

    iptables-restore < /etc/iptables.test.rules(改完后先加载规则) 
    iptables-save > /etc/iptables.rules(保存规则)

    二SSH问题

    1 ssh运行状态 
    service sshd status

    如果出现 
    Loaded: error (Reason: No such file or directory) 
    说明ssh没有安装 
    检查是否装了ssh包 
    rpm -qa|grep ssh 
    没?的话 
    yum install openssh-server 
    或者 
    yum install sshd 
    (卸载ssh服务)yum remove sshd

    如果出现 
    openssh-daemon is stopped 
    说明安装了ssh但是没有开启 
    即时生效,重启失效 
    service sshd start 
    service sshd stop 
    永久生效 
    chkconfig sshd on 
    chkconfig sshd off

    2修改ssh默认端口22(本例改为3547) 
    vi /etc/sysconfig/iptables 
    加入 
    -A INPUT -m state –state NEW -m tcp -p tcp –dport 3547 -j ACCEPT 
    重启防火墙 
    /etc/init.d/iptables restart 
    (可选) 
    可根据你的ssh状况屏蔽22端口 
    vi /etc/sysconfig/iptables 
    在 
    -A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT 
    前面加上#注释掉此语句 
    记得重启防?墙

    安装semanage 
    yum -y install policycoreutils-Python 
    开放指定端口 
    semanage port -a -t ssh_port_t -p tcp 3547 
    重启ssh服务 
    /etc/init.d/sshd restart 
    查看端口情况 
    semanage port -l|grep ssh 
    应该能看到 
    ssh_port_t tcp 3547, 22

    3查看端口状态 
    netstat -antulp|grep ssh

  • 相关阅读:
    (元)黄公望---富春山居图(中国十大传世名画之八) 高清图下载
    Bloom Filter 原理与应用
    开始我的 JNI 入门吧
    javaScript的使用
    hash定义
    POJ3169 Layout(差分约束系统)
    青蛙的约会
    POJ 3414 Pots ( BFS , 打印路径 )
    你真的理解Java的this和super吗?
    十款优秀的在线JavaScript工具介绍
  • 原文地址:https://www.cnblogs.com/saryli/p/11831736.html
Copyright © 2011-2022 走看看