Linux enable specified user login, cancel root ssh login

Source: Internet
Author: User

As we all know, FreeBSD ssh default login is not directly log in with root, so that you can protect against some SSH sniffer attacks, and secondly, ordinary user operations can avoid some "security incidents." But unfortunately, the CentOS series default SSH can be root directly login, so the harm is too large, the shell written below this article, will greatly simplify the configuration of CentOS Normal user ssh login, to avoid errors caused by SSH login failure.

#!/bin/bash#desc:written by cuixh blog.zjyxh.comuseradd userecho "user" >/etc/sshuserssed-i ' 1aauth required Pam_lis tfile.so item=user sense=allow file=/etc/sshusers onerr=fail '/etc/pam.d/sshdsed-i "12aPort $RANDOM"/etc/ssh/sshd_ Configsed-i "s/#PermitRootLogin yes/permitrootlogin no/"/etc/ssh/sshd_configsed-n "13p"/etc/ssh/sshd_config/sbin/ Service sshd Restart

Copy this script to chssh.sh and execute the script in the current directory. For example, Bash chessh.sh. or download ready-made chssh.sh, such as wget Http://docs.zjyxh.com/linux/system/chssh.sh;bash chssh.sh;

Finally set user user password, passwd user


This article is from the "Tri Xiaohui blog" blog, make sure to keep this source http://coralzd.blog.51cto.com/90341/1699439

Linux enable specified user login, cancel root ssh login

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.