SSH configuration in Linux

Source: Internet
Author: User
& Nbsp; ssh is a common method for users to log on to Linux servers. However, for security considerations, we sometimes need to perform some special processing on ssh. This article records some of the changes I have made, for your reference. 1. modify ssh Port ssh to port 22 by default. if you need to change it to another port, you can modify/etc/ss ssh to be a common logon method for Linux servers, however, for the sake of security, sometimes we need to do some special processing for ssh. This article records some of the changes I have made for your reference.

1. modify the ssh Port

Ssh uses port 22 by default. if you need to change it to another port, you can modify the/etc/ssh/sshd_config file

# Port 22

Comment out, modify it to the required Port (such as 8888), and then run the following command to restart the ssh service:



Service sshd restart

2. disable the remote ssh logon permission of the root user

If you do not want the root user to log on remotely, follow these steps:
Vi/etc/ssh/sshd_config
Set
# PermitRootLogin yes
Comment out, change yes to no, and restart the ssh service (reboot is recommended here)

3. disable remote logon for certain users

1. modify/etc/pam. d/sshd

Add a line after # % PAM-1.0:

Auth required pam_listfile.so item = user sense = allow file =/etc/ssh_users onerr = fail

2. enable user remote logon (for example, allow abc remote logon ):

Echo abc>/etc/ssh_users

3. disable remote logon:

Rm-rf/etc/ssh_users

In the above example, the file is simply deleted. In fact, if a user is not allowed to log on, delete the user from the ssh_users file.
 

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.