Quickly and securely create user accounts for Linux operating systems

Source: Internet
Author: User
Article Title: quickly and securely create a Linux operating system user account. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

If you need to create a user account to allow access to the system shell, the only logical choice for the logon tool is OpenSSH. All you need is the public key of the user. The user only needs your IP address or host name (the user needs to log on here ). Generally, this is enough.

Sometimes, users may need to know what their passwords are. If you need to use the Sudo program, you must use a password for authentication. Ideally, this information is provided by phone or encrypted email, but the password itself is sometimes provided through an email in plaintext or plain text.

Ideally, create a user account, obtain the user's SSH public key, and create a random password for the user. After the user logs on, change the password immediately. These are easy to complete.

This is quite simple for users. To create a pair of public/private keys, run the following command:

$ Ssh-keygen-t dsa

You should also ask the user to send ~ /. Ssh/id_dsa.pub file. On the server side, things are not too difficult. First, you need to create a user account:

# Useradd-c "Joe User"-s/bin/bash-m joe

# Openssl rand-base64 6 | tee-~ Joe/. password | passwd-stdin joe

This creates a user named joe, assigns a random password to the user, and stores the same password in ~ In joe/. password, joe can see the password here.

If you have locked your account through/etc/ssh/sshd_config, remember to add the following command to allow joe to access the system:

AllowUsers joe

In addition, set PasswordAuthentication to no to force all logins to use the public key.

Finally, you must copy the id_dsa.pub key to your home directory and assign the following ownership and permissions:

# Mkdir ~ Joe/. ssh

# Chmod 700 ~ Joe/. ssh

# Cp id_dsa.pub ~ Joe/. ssh/authorized_keys

# Chmod 600 ~ Joe/. ssh/authorized_keys

# Chown-R joe: joe ~ Joe/. ssh

All right, all done. Now users can use their SSH private key to log on, and can access Sudo or need an actual password for authentication.

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.