Detailed steps for modifying the default ssh port in centos

Source: Internet
Author: User
Tags ssh vps ssh port

1. Modify the s h Port

The default s h port of VPS is 22. To prevent MJJ from scanning the port to crack the password, it is necessary to change the ssh port to another number.
Now, log on to the VPS through SSH and modify the configuration file.

Vi/etc/ssh/sshd_config

Find # Port 22, remove the previous #, and change it to Port 1520 (the number should be 4 digits as much as possible to avoid being occupied), and then restart it to take effect.

CentOS restart SSH: service sshd restart
Debian restart SSH: service ssh restart

2. Prohibit ROOT account login

If we disable the ROOT account and add an account we know, we cannot at least guess the password.

First, add the user name.

Useradd zxsdw

Set password for new user name

Passwd zxsdw

Second, prohibit root login

Vi/etc/ssh/sshd_config

Locate PermitRootLogin yes, remove the previous #, change yes to no, save and restart ssh.

Finally, log on to the newly added user.


Log in and use the su root command to escalate permissions so that new users have ROOT management permissions.


Example:


Login as: zxsdw # New User name
Password: ***** # New user password
Su root # Elevation of Privilege
Password: ***** # Original ROOT Password

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.