How to enable the root user to log in remotely under Linux

1. Background

In many cases, remote login uses the user identity to log in, and the files in the system path cannot be downloaded directly through the user role. For downloading, you need to move the file to a path that the current user has permission to download, which is troublesome. Another download method is to log in to the system as the root user to download from the original path. However, in order to improve system security, most SSHs disable root remote login authority by default . You need to manually configure SSH to allow root remote login. Taking the Ubuntu system as a reference, the specific operations are as follows.

2. Configure SSH

  • Find configuration files
# 一般为这个路径:
/etc/ssh/sshd_config
# 无此路径的情况下直接查找配置文件
find / -name *sshd_config
  • Modify the configuration file
vim /etc/ssh/sshd_config
# 键入i进入编辑模式,加入以下内容。wq保存
PermitRootLogin yes

configuration file

3. Restart the service process

3-1. The difference between SSH and SSHD processes

The main difference between SSH and SSHD is active or passive connection:

  • SSH is the client's active remote control of other devices, that is, the server;
  • SSHD is a server that passively receives SSH requests from other devices.

The specific differences are summarized as follows:

category SSH SSHD
definition SSH is the abbreviation of Secure Shell, which is an encrypted network protocol for remote login and secure file transfer. SSHD is the abbreviation of SSH Daemon, which is the SSH software daemon running on the server side.
effect It is used for operations such as remote connection, remote management and file transfer. As a server-side software, it receives connection requests from clients and provides them with secure remote login and file transfer functions.
Operating position run on the client . run on the server .
The port number Port 22 is used by default. Port 22 is used by default.
User Authentication Authentication is by username and password. Support multiple user authentication methods, including user name and password, public key authentication, Kerberos authentication, etc.
safety Based on public key encryption technology, a combination of symmetric encryption and asymmetric encryption is used to ensure the security of data transmission. The security and integrity of data in the communication process are guaranteed through digital certificates and encryption algorithms.
scope of use Applicable to Linux, Unix, Mac OS and other operating systems. Applicable to Linux, Unix, Mac OS and other operating systems.

3-2. Restart SSHD to take effect configuration

The following command restarts the SSHD service, the two commands are equivalent:

systemctl restart sshd
# 或
service sshd restart

Executing the above command will restart the SSHD service, that is, restart the entire SSH server process , and reload the configuration file at the same time . This command is usually used to set and debug the SSH server, or to make the SSH service configuration take effect after modification. Executing this command does not affect other running processes, but only restarts the SSH service process.

4. Root users download files

4-1. Root user remote login

Use remote login software or platform to fill in the root name and Linux device IP. Here I am using MobaXterm . After authentication, you will be asked to enter the root password, and you can log in:
log in page
the login is successful as follows, and enter the Linux server shell panel:
Please add a picture description

4-2. Download files

Use ftp download tools: such as FileZilla, xftp, MobaXterm (integrated into the software), also enter the Linux IP, user name (root), password and port (22) to log in to the remote device, enter the file path to be downloaded, and drag the file Download it to the local path:
FileZilla page

Guess you like

Origin blog.csdn.net/qq_44281591/article/details/130974373