CentOS 7.0 Modify SSH default connection 22 port and add firewall Firewalld via port

Source: Internet
Author: User

The first thing to do is to modify the default port of SSH 22

Need to modify file

/etc/ssh/sshd_config

Using commands

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 is compiled with path=/usr/local/bin:/usr/bin# the strategy used for Options in the default Sshd_config shipped with# OpenSSH are 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 that you had to tell# SE Linux 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-Hostkey for protocol version 1#h ostkey/etc/ssh/ssh_host_key# hostkeys for protocol version 2hostkey/etc/ssh/ssh_host_rsa_key#hostkey/etc/ssh/ssh_ host_dsa_keyhostkey/etc/ssh/ssh_host_ecdsa_key# Lifetime and sizeof ephemeral version 1 server key#keyregenerationinterval 1h#serverkeybits 1024# ciphers and keying#rekeylimit default non e# logging# obsoletes quietmode and fascistlogging#syslogfacility authsyslogfacility 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_key s2# but the overridden so installations would only check. ssh/authorized_keysauthorizedkeysfile. Ssh/authorized_ke Ys#authorizedprincipalsfile None#authorizedkeyscommand None

You do the port modifications first, and then you need to get the firewall through this port.

CentOS 7 uses FIREWALLD by default so let's see if it runs

Firewall-cmd--state

And then see what the default ports are.

View port rules

Firewall-cmd--permanent--list-port

Just test added port now remove this port parameter --permanent is permanently configured The machine restart is still valid

Delete Port

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

Add Port to firewall exception

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

Then through the Putty SSH connection software link is good ~

FIREWALLD Reference

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

CentOS 7.0 Modify SSH default connection 22 port and add firewall Firewalld via port

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.