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 to change SSH port number under Linux

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

In this article, the editor introduces in detail "how to change the SSH port number under Linux". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to change the SSH port number under Linux" can help you solve your doubts.

SSH is the abbreviation of Secure Shell; SSH is a security protocol based on the application layer. SSH is currently a reliable protocol designed to provide security for remote login sessions and other network services. The default port is 22, but the SSH port number needs to be changed due to the company's business needs.

First, install ssh

Ssh software consists of two parts: ssh server and ssh client. The configuration file for ssh is in the / etc/ssh/ directory, where the server configuration file is sshd_config and the client configuration file is ssh_config. Install ssh, here, only describe the method of installing through yum (provided your yum source is configured correctly and can be used):

# yum install openssh-*-y//yum automatically installs all openssh-related software packages II. Configure ssh server

According to the two authentication methods of ssh, configure two login methods that do not have a security level. Log in through password authentication 1. Open the sshd_config configuration file with the vim editor

# vim / etc/ssh/sshd_config

two。 Make the following changes to the configuration file (which can be adjusted according to your actual situation):

Port 22 / / uses port 22 by default, or you can modify it to other ports by yourself. However, you need to log in with the port number # ListenAddress / / to specify the IP that provides ssh services. I will comment out here. PermitRootLogin / / disable remote login with root PasswordAuthentication yes / / enable password authentication mode PermitEmptyPassword / / disable login to LoginGraceTime 1m / / repeat authentication time is 1 minute MaxAuthTimes 3 / / maximum number of retries to verify save the modified configuration and exit.

These are common ssh service scaffolding configurations. Next, let's focus on today's focus, the modification of the port number.

Modify the default port

Open the ssh port configuration file: vim / etc/ssh/sshd_config, find the port shown below, change it to the port you want to change, or open multiple ports at the same time:

two。 You need to close SELinux, open the configuration file: vim / etc/selinux/config, set SELINUX=disabled, save exit: wq

3. Restart the sshd service:

Systemctl restart sshd.service

, or restart the computer: reboot

4. Check to see if the port is open:

Netstat-ntpl | grep 3389

(if the picture shows it is turned on)

After reading this, the article "how to change the port number of SSH under Linux" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it yourself to understand it. If you want to know more about related articles, please follow the industry information channel.

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

Development

Wechat

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

12
Report