Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Set key to log in on linux and add sudo permissions to ordinary users

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Take the xshell connection tool as an example

Generate secret key

Select RSA as the key type. Next step

Name customization. Next step

You can save a copy of the key to the computer and finish it.

The picture below is the private key, or you can save a copy to the computer.

The private key is reserved for connecting to the server, and the public key is transferred to the server configuration file (how to pass it later)

Operations on the server

1. Transfer the public key to the server under the root directory

two。 Execute the command to write to the key profile

Ssh-keygen-X-f xjw.pub > > / root/.ssh/authorized_keys2

The error is reported because there are no .ssh directories and files. The solution is to link to the server.

Command line input: ssh localhost

Execute it again and you will have: ssh-keygen-X-f xjw.pub > > / root/.ssh/authorized_keys2

1. Modify the configuration file: vim / etc/ssh/sshd_config

Modify ssh connection port (default 22, modify if necessary): search for Port

two。 Modify access key file path

Search for AuthorizedKeysFile, which is commented out by default, and accesses the .ssh / authorized_keys file. If you want to change it or not, I have created a new authorized_keys2 here.

3. Modify and cancel password login

Search PasswordAuthentication and change yes to no

Note: if you find a machine that can neither log in with a password nor log in with a key, you need to check these two lines of configuration files to see whether they have been uncommented and changed to no. Both are allowed by default.

# RSAAuthentication yes

# PubkeyAuthentication yes

Restart the sshd service: service sshe restart

Add sudo permissions to ordinary users

Create a normal user

[root@localhost ~] # useradd test1

Add permission

Modify the configuration file:

[root@localhost ~] # vim / etc/sudoers

Find the configuration of the root user and add it below him.

Note: user's method of changing password

Local user changes password: passwd

Change other user passwords: passwd username

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report