Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How CentOS6.5 and CentOS7 ssh modify the default port number

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how CentOS6.5 and CentOS7 ssh modify the default port number. I hope you will get something after reading this article. Let's discuss it together.

This paper gives an example of how CentOS6.5 and CentOS7 ssh modify the default port number. Share with you for your reference, the details are as follows:

CentOS6.5ssh modifies the default port number

First check the server port number range:

# sysctl-a | grep ip_local_port_rangenet.ipv4.ip_local_port_range = 32768 61000

The new ssh port number is within this range, such as 41134

Step one:

Vi / etc/sysconfig/iptables

Find the existing ssh line and change 22 to the new SSH port number 41134

The modified configuration should be

-An INPUT-p tcp-m state-- state NEW-m tcp-- dport 41134-j ACCEPT#service iptables save (save firewall configuration) # service iptables restart (restart firewall)

Step 2:

# vi / etc/ssh/sshd_config

Change line 22 of Port to Port 41134

Restart the ssh service

# service sshd restart

Remember, the first step and the second step can not be reversed, otherwise the SSH remote connection will not be possible.

Centos7 ssh modifies the default port number

Modify the ssh configuration file / etc/ssh/sshd_config, remove the comments in front of Port 22, and change 22 to 4211

Whereis sshssh: / usr/bin/ssh / etc/ssh / usr/share/man/man1/ssh.1.gzcd / etc/sshllnano sshd_config

Modify iptables Firewall: / etc/sysconfig/iptables

-An INPUT-p tcp-m state-- state NEW-m tcp-- dport 22-j ACCEPT-An INPUT-p tcp-m state-- state NEW-m tcp-- dport 22-j ACCEPT-An INPUT-p tcp-m state-- state NEW-m tcp-- dport 4211-j ACCEPT

Restart iptables

Systemctl stop iptablessystemctl start iptablessystemctl status iptables

Restart sshd

Systemctl status sshd has finished reading this article, I believe you have some understanding of "how to modify the default port number of CentOS6.5 and CentOS7 ssh". If you want to know more about it, please follow the industry information channel. Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report