Home >Computer Tutorials >Computer Knowledge >Install SSH on the Linux Debian11 server, create a new user and allow SSH remote login, and configure SSH secure login!

Install SSH on the Linux Debian11 server, create a new user and allow SSH remote login, and configure SSH secure login!

PHPz
PHPzforward
2024-03-01 19:16:241443browse

Linux Debian11服务器安装SSH,创建新用户并允许SSH远程登录,及SSH安全登录配置!

The steps to install SSH on a Debian 11 server and create a new user to allow SSH remote login are as follows:

Step 1: Install SSH

In order to install an SSH server, you need to be logged in to your Debian 11 server as root or a user with sudo privileges.

Execute the following command in the terminal to install the SSH server:

sudo apt update
sudo apt install openssh-server

Step 2: Create a new user

To create a new user, you can use the
adduser command. Replace the following command with your desired username:

sudo adduser new_username

You will be prompted to set the new user's password and other details.

Step 3: Allow SSH remote login

By default, the SSH server installed on the Debian 11 server should allow remote login. However, to make sure it has been configured correctly, you can edit the SSH server configuration file.

Open the SSH configuration file using the following command:

sudo nano /etc/ssh/sshd_config

In the file, look for the following lines:

#PermitRootLogin yes

Change it to:

PermitRootLogin no

This will disable SSH logins using the root user. This is for added security. If you still want the root user to be able to log in remotely, change the above line back to
PermitRootLogin yes.

Step 4: Configure SSH secure login

You can further enhance the security of SSH by disabling password authentication and enabling public key authentication.

Find the following line:

#PasswordAuthentication yes

Change it to:

PasswordAuthentication no

This will disable password authentication. Then, find the following line:

#PubkeyAuthentication yes

Change it to:

PubkeyAuthentication yes

This will enable public key authentication.

Save and close the file.

Step 5: Restart the SSH service

After completing the above changes, you need to restart the SSH service for the changes to take effect.

Use the following command to restart the SSH service:

sudo systemctl restart ssh

现在,您应该能够使用新创建的用户通过SSH远程登录到您的Debian 11服务器了。

这些步骤提供了在Debian 11服务器上安装SSH,创建新用户并允许SSH远程登录以及进行SSH安全登录配置的指南。请确保按照步骤操作,并根据您的需求进行必要的修改。

The above is the detailed content of Install SSH on the Linux Debian11 server, create a new user and allow SSH remote login, and configure SSH secure login!. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:mryunwei.com. If there is any infringement, please contact admin@php.cn delete