centos 7.0 修改ssh默认连接22端口 和 添加防火墙firewalld 通过端口

首先 先做的就是 修改ssh的默认端口22

需要修改文件

/etc/ssh/sshd_config

使用命令

vi /etc/ssh/sshd_config

[[email protected] ~]# vi /etc/ssh/sshd_config
#       $OpenBSD: sshd_config,v 1.90 2013/05/16 04:09:14 dtucker Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/bin:/usr/bin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
Port 48489
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

# The default requires explicit activation of protocol 1
#Protocol 2

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key

# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 1024

# Ciphers and keying
#RekeyLimit default none

# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#RSAAuthentication yes
#PubkeyAuthentication yes

# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile      .ssh/authorized_keys

#AuthorizedPrincipalsFile none

#AuthorizedKeysCommand none

  先做就完成了 端口的修改 然后就需要让防火墙通过这个端口

centos 7 默认使用的 是 firewalld  所以先看看是否运行

firewall-cmd --state

然后看下 先做默认通过的端口都有哪些

查看端口 规则

firewall-cmd --permanent --list-port

刚才测试 添加了 端口 现在删除这个端口 参数--permanent 是永久配置 机子重启依然有效

删除端口

firewall-cmd --permanent --remove-port=48489/tcp

添加端口 到防火墙例外

firewall-cmd --permanent --zone=public --add-port=48489/tcp

然后通过putty ssh连接软件链接一下就好了~

firewalld 参考资料

http://blog.csdn.net/smstong/article/details/39317277

时间: 2024-08-27 02:45:23

centos 7.0 修改ssh默认连接22端口 和 添加防火墙firewalld 通过端口的相关文章

centos 6.4 修改ssh默认端口22为其他端口详尽安全教程(包含SELinux,iptables设置)

该教程是目前最安全的教程,如果你是新手请严格按照教程的步骤进行,如果是有一定基础的人可以选择性跳过某些段落 修改端口配置 先运行 vim /etc/ssh/sshd_config 找到#Port 22 这行然后去掉前面的注释,然后再下面加一行 Port 1234 Port 22 Port 1234 很多教程是直接修改22为其他端口,最好不要这样做,万一修改的端口不能用,你就完全登陆不上了,所以先留一条后路 修改防火墙配置 修改iptables(linux 的防火墙)文件: vim /etc/sy

RHEL7.0修改SSH默认端口及SELinux运行状态修改

Linux系统安装好后,默认会开启SSH服务以便远程配置.但使用默认端口22不安全,一般不建议使用默认端口,那就需要修改SSH默认端口.在RHEL7.0上修改和7.0以下类似,但要注意SELinux的修改. SSH 为 Secure Shell,由IETF的网络工作小组(Network Working Group)所制定:SSH 是建立在应用层和传输层基础上的一种安全协议.SSH传输数据是加密的,可以有效防止传输过程被截取数据保障安全.SSH的数据是经过压缩的,所以可以加快传输的速度. 修改步骤

CentOS修改SSH默认端口

1. 修改配置文件 vim /etc/ssh/sshd_config 修改 #Port 22 这行,  去掉 #  修改后面的端口号 例如 Port 2123 重启sshd服务 /etc/init.d/sshd restart 2. 修改防火墙配置 vim /etc/sysconfig/iptables 可以参照已有的配置去修改, 比如 -A INPUT -m state --state NEW -m tcp -p tcp --dport 2123 -j ACCEPT 重启防火墙 /etc/in

RHEL7 修改SSH默认端口及修改SELinux运行状态

RHEL7安装后,默认开启SSH服务以便远程配置,但默认端口22并不安全,一般不建议使用默认端口,那就修改SSH默认端口.在sshd_config里面的修改RHEL7.0上修改和7.0以下类似,但要注意SELinux的修改. 修改步骤: 1.查看是否已安装SSH软件包  # rpm -qa|grep ssh 2.检查服务是否开启  # systemctl status sshd.service 3.检查进程运行状态  # ps -ef |grep sshd 4.检查程序运行端口 # netsta

CentOS7修改SSH远程连接端口

CentOS7修改SSH远程连接端口 原文地址:https://www.cnblogs.com/xiaofengchu/p/8413377.html

Linux Centos 6.9中SSH默认端口修改的坑

关于Linux Centos6.5的SSH默认端口修改的博客有一大堆,我在这里就不啰嗦了,但是面对Centos 6.9,就会发现有一个巨坑: 修改iptables之后执行下面的命令后: # service iptables save 会发现dport 修改失败,端口号仍为22, 此时,你会很郁闷的发现无论怎么修改都不生效, 重点来了,我尝试了无数次之后发现, 先执行以下命令: # service iptables restart 此时,竟然修改成功了,然后修改sshd的配置文件,此时生效了, 然

LINUX/CENTOS 中修改SSH默认端口号

在linux中,默认的SSH端口号为22,由于这是大家都知道的端口号,一旦有入侵者进行端口扫描的时候扫描出22端口,就立马知道这是进行SSH登录的端口号,因此我们需要修改默认的端口号,让入侵者即使扫描出端口号也不能立马知道此端口作用. 1.修改防火墙端口号 在这里我们是要将默认的ssh端口22修改为2121,所以要将2121端口在防火墙打开 # /sbin/iptables -I INPUT -p tcp --dport 2121 -j ACCEPT # /etc/rc.d/init.d/ipt

centos6.X修改ssh默认端口号

先查看下服务器端口号范围: # sysctl -a|grep ip_local_port_range net.ipv4.ip_local_port_range = 32768    61000 新ssh端口号在这个范围内即可,如41134 第一步: vi /etc/sysconfig/iptables 找到现有的ssh那行,把22修改为新的SSH端口号41134 修改后的配置应为 -A INPUT -p tcp -m state --state NEW -m tcp --dport 41134

CentOS 7.0如何关闭默认防火墙开启IPtables?~

操作系统环境:CentOS Linux release 7.0.1406(Core) 64位CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤.1.关闭firewall:systemctl stop firewalld.service #停止firewallsystemctl disable firewalld.service #禁止firewall开机启动firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,