Change the ssh port and disable root remote logon in Linux

Source: Internet
Author: User
Tags ssh port

Change the ssh port and disable root remote logon in Linux

We all know that the default ssh port number is 22. To change the port number to 9688, You need to edit the/etc/ssh/ssh_config and/etc/ssh/sshd_config files;

To disable remote root logon, edit/etc/ssh/sshd_config. (Some Linux directories may be/etc/sshd. Please modify them as needed)

Refer to: Linux to modify SSH ports and disable root remote login settings

The procedure is as follows:

1. Edit the/etc/ssh/ssh_config file:

Root@www.bkjia.com ~ # Cat/etc/ssh/ssh_config | grep Port

Port 9688

Remove the comment symbol "#" before the commented-out Port 22, and change 22 to 9688 above. Save and exit.

2. Edit the/etc/ssh/sshd_config file:

# Vim/etc/ssh/sshd_config

Find PermitRootLogin and change "yes" to "no", so that the root user cannot log on remotely. Save and exit.

3. Restart ssh:

#/Etc/init. d/ssh restart

In this way, the ssh port number is successfully changed and root remote logon is disabled. It is worth mentioning that if your Linu x contains only root users, you must create a new user before disabling root remote logon, otherwise, ssh cannot be used to remotely log on to the server!

The content in this article is tested in Ubuntu. commands in other Linux systems are similar.

This article permanently updates the link address:

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.