Ways to prevent root ssh from being logged in and modifying SSH ports in Linux

Source: Internet
Author: User
Tags ssh

1, prohibit the root user login ssh

The code is as follows:
#vi/etc/ssh/sshd_config

Put

The code is as follows:
Permitrootlogin Yes

To

The code is as follows:
Permitrootlogin No

Restart the sshd service

The code is as follows:
#service sshd Restart

Using root login At this point will be prompted to reject:

The code is as follows:
Login As:root
Root@192.168.8.100 ' s Password:
Access denied

2. Modify SSH default port

The code is as follows:
Vi/etc/ssh/sshd_config

Find #port 221, here is the identity default use 22 port, modified to the following:

The code is as follows:
Port 22
Port 7000

And then save the exit
Restart the sshd service

The code is as follows:
#service sshd Restart

Note: Use 22 ports and 7000 at this time should all be logged in, so that you can avoid debugging errors (such as adjusting the port after the corresponding firewall policy is not adjusted) to prevent the use of SSH logon server situation.
Use the SSH client and 7000-port login test, and then restart the sshd service with the/etc/ssh/sshd_config configuration file's port 221 comment.

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.