zoukankan      html  css  js  c++  java
  • centos7修改ssh端口

    一、修改ssh配置文件

    vi /etc/ssh/sshd_config   在Port 22下面加上Port  59157,我这里是以59157端口为例

    二、向防火墙中添加新的ssh端口

    firewall-cmd --zone=public --add-port=59157/tcp --permanent     新增ssh端口

    firewall-cmd --reload    重新加载防火墙,否则新增端口不能生效

    firewall-cmd --zone=public --list-all  验证一下新端口是否添加上

    三、向SELinux中添加新的SSH端口

    /usr/sbin/sestatus   如果是disabled就不用管了,如果是enable就需要往下进行

    semanage port -l | grep ssh                查询当前ssh服务端口,系统提示bash: semanage: command not found,这时我们要安装SELinux的管理工具semanage

    yum install policycoreutils-python       运行 semanage 需要先安装其依赖工具包 policycoreutils-python

    semanage port -l | grep ssh    查询当前 ssh 服务端口

    semanage port -a -t ssh_port_t -p tcp 59157  向SELinux中添加新的ssh端口  

    semanage port -l | grep ssh  验证ssh端口是否添加成功

    systemctl restart sshd.service  最好检查一下所有配置以及新端口是否可以连接,检查好后再重启ssh服务,如果确认没问题最好在配置文件里把默认22端口注释

    为确保万无一失,重启2次机器

  • 相关阅读:
    centos6.4下django1.11.3项目的部署
    inner join和left join 、right join 的区别?
    php中的对象赋值
    windows下Call to undefined function curl_init() error问题
    include和require的区别误区
    第一车网笔试题
    借贷宝笔试题
    40斤西瓜3人分,求分法
    走楼梯算法
    ip地址分类
  • 原文地址:https://www.cnblogs.com/leon2659/p/9401231.html
Copyright © 2011-2022 走看看