Linux Add New User and SSH Remote Login Tutorial

To add a new user on a Linux system and allow it to SSH remote login, you can follow the steps below:

  1. Log in to the Linux server as the root user.
  2. Create a new user with the following command (  newusersubstitute your desired username):

    useradd newuser
  3. Set the new user's password (will  newuserbe replaced with the username you created):

    passwd newuser
  4. Grant new users SSH login permissions, which can be set by editing the SSH configuration file. Open the file with a text editor  /etc/ssh/sshd_config.
  5. Find the following lines and modify them (you can add them in the file if you don't find them):

    # 将以下行的注释去掉(删除行首的#符号)
    AllowUsers newuser
  6. Save and close the file.
  7. Reload the SSH service for the changes to take effect. The SSH service can be restarted with the following command:

    systemctl restart sshd

Now, you have successfully created a new user and allowed this user to remotely log in to the Linux server via SSH.

Make sure to choose strong passwords when setting up passwords for new users, and manage user access properly. Also, if you are using a firewall, make sure your firewall is configured to allow SSH traffic.

Hope the above tutorial will help you to add a new user and allow SSH remote login on your Linux system. According to specific needs, you can make appropriate adjustments and customizations according to your own situation.

Guess you like

Origin blog.csdn.net/tiansyun/article/details/132268005