Linux Restricts user Login

Source: Internet
Author: User

First: Create two ordinary users User1 and User2

[Root@lyt ~]# Useradd user1

[Root@lyt ~]# passwd user1 #创建密码

[Root@lyt ~]# useradd User2

[Root@lyt ~]# passwd user2 #创建密码

1, prohibit individual user login. For example, disable User1 user login.

[Root@lyt ~]# passwd-l user1 #使用-l Directive locks user1 so that it cannot log on, but can switch from the root account to the User1 user

[Root@lyt ~]# passwd-s user1 #-s indicates the status of the user User1 view

[Root@lyt ~]# passwd-u user1 #-u can release the locked user password

2: The user login in the modified/etc/passwd file

[Root@lyt ~]# vim/etc/passwd

[Root@lyt ~]# Su–user1 #登录到user1

3: Create/etc/nologin file, except root can log in, other users can not log in

(in Tty1-7, ordinary users can log in, but use other terminal normal users cannot)

Two: Limit root user Login modification/etc/securetty

1. If you want the root user to be unable to log in from Tty2, you can remove the Tty2 from the/etc/securetty:

2. If you want to allow a normal user Telnet login:

[Root@lyt ~]# Mkdir/mnt/cdrom

[Root@lyt ~]# mount/dev/cdrom/mnt/cdrom/

[Root@lyt ~]# cd/mnt/cdrom/server/

[Root@lyt server]# rpm-ivh telnet-server-0.17-39.el5.i386.rpm #安装telnet-server

[Root@lyt server]# Vim/etc/xinetd.d/telnet

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.