Linux 6 steps to change the default remote port number of ssh

Linux 6 steps to change the default remote port number of ssh

The default ssh remote port in Linux is 22. Sometimes the default port will be scanned or attacked by people with ulterior motives. In order to make our system more secure, we need to change the remote port number.

Steps:

1. Modify the ssh_config configuration file

vim /etc/ssh/sshd_config

2. Find the line #Port 22 in the configuration file (the default port is 22)

3. Modify this line to the port number you want

Port 222 (Note: remove the leading # sign)

4. [Optional] If you want to add a port number (port 22 and port 222 are effective at the same time)

Port 22 (Note: no # sign in front)
Port 222 (Note: no # sign in front)

5. After exiting, restart the sshd service

/etc/init.d/sshd restart

If you have a firewall set up, you need to add new port rules

6. Edit iptables file

vim /etc/sysconfig/iptables

7. Add port 222 rules

-A INPUT -m state –state NEW -m tcp -p tcp –dport 222 -j ACCEPT

8. Save and exit and restart the iptables service

service iptables restart

9. Test the connection and call it a day.

Summarize

The above is the steps for changing the default remote port number of ssh in Linux 6. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • Install OpenSSH on Windows and log in to the Linux server by generating an SSH key
  • How to upload files and folders to Linux server via SSH
  • Novice learn Linux commands: ssh command (remote login)
  • How to solve the problem of Linux ssh remote connection disconnection
  • SSH login and configuration method under Linux system
  • Method for modifying vnc configuration port number based on Linux
  • Detailed explanation of Linux to view the open port number of the server

<<:  Detailed steps for installing and configuring MySQL 8.0 on CentOS 7.4 64-bit

>>:  Solution to automatically trigger click events when clicking on pop-up window in Vue (simulation scenario)

Recommend

Practical method of deleting associated tables in MySQL

In the MySQL database, after tables are associate...

Detailed steps to deploy SpringBoot projects using Docker in Idea

Preface Project requirements: Install the Docker ...

MySQL 5.7.25 installation and configuration method graphic tutorial

There are two types of MySQL installation files, ...

Hbase installation and configuration tutorial under Linux

Table of contents Hbase installation and configur...

How to reset the initial value of the auto-increment column in the MySQL table

How to reset the initial value of the auto-increm...

JavaScript countdown to close ads

Using Javascript to implement countdown to close ...

Steps to set up HTTPS website based on Nginx

Table of contents Preface: Encryption algorithm: ...

The process of installing MySQL 8.0.26 on CentOS7

1. First, download the corresponding database fro...

React configuration px conversion rem method

Install related dependencies npm i lib-flexible -...

CSS to achieve particle dynamic button effect

Original link https://github.com/XboxYan/no… A bu...

How to configure Nginx to support ipv6 under Linux system

1. Check whether the existing nginx supports ipv6...

Add ?v= version number after js or css to prevent browser caching

Copy code The code is as follows: <span style=...