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

Basic configuration in Linux system

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Modify CentOs basic information, create user authorization, and ssh secret-free login configuration

1 permanently modify the hostname

Sudo vim / etc/hostname

Change the original hostname xxx to master (on the slave host to the corresponding slave)

Sudo vim / etc/hosts

Change xxx in / etc/hosts to the hostname that has just been changed, and change the previous ip address to the actual ip address

Reboot / / restart

2 create a user and authorize it

Create a user zhjc recommendation:

[root@slave5 ~] # adduser zhjc [root@slave5 ~] # passwd zhjcNew password: # enter password Retype new password: # enter password passwd: all authentication tokens updated successfully.

Find the path to the sudoers file and give root user write permission

[root@slave5~] # whereis sudoers # find sudoers file path / / display: sudoers: / etc/sudoers / etc/sudoers.d / usr/share/man/man5/sudoers.5.gz [root@slave5~] # ls-l / etc/sudoers # View permissions / / display: 4-r Murray r-1 root root 3938 Sep 6 2017 / etc/sudoers # Only read access [root@slave5~] # chmod-v UCPW / etc/sudoers # Grant read and write access / / display: mode of'/ etc/sudoers' changed from 0440 (RMurray r -) to 0640 (rw-r-)

Modify the sudoers file

[zhjc@slave5 ~] # vim / etc/sudoers

Modify sudoers file, add new user information: press shift + I to modify file

Root ALL= (ALL) ALLzhjc ALL= (ALL) ALL / / this is a new user

Revoke the write permission of the root user

[root@slave5] # chmod-v Umurw / etc/sudoers

3 create the corresponding folder and authorize the corresponding users

Create a folder soft in the root directory

[zhjc@slave5 ~] # sudo mkdir / soft// enter the password of the zhjc user [zhjc@slave5 ~] # ll / View all folders in the root directory [zhjc@slave5 ~] # sudo chown-R zhjc:zhjc / soft [zhjc@slave5 ~] # ll / View all folders in the root directory again

Introduction to SSH

SSH (Secure+SHell): is a network protocol, as its name implies, is a very secure shell, mainly used for encrypted transmission between computers. SSH service implements encrypted data transmission based on asymmetric encryption (public-key cryptograthy, also known as public key encryption) technology. This technique generates a pair of keys, one of which encrypts the data and can only be used for encryption, while the other can only be used for decryption. The data encrypted with the encryption key can only be decrypted with the corresponding decryption key. And only one of the keys is known, and the other cannot be calculated. Therefore, if one of a pair of keys is disclosed, the other key is not compromised. A public key is usually called a public key, and a private key is called a private key (private key).

4 ssh secret-free login

Install ssh: enter "sudo apt-get install openssh-server"-- > enter-- > enter "y"-- > enter-- > installation is complete.

Open the "terminal window" and type "sudo ps-e | grep ssh"-- > enter-- > sshd, indicating that the ssh service has been started. If it is not started, enter "sudo service ssh start"-> enter-> ssh service will start.

Set up ssh login machine without password

To create ssh-key, we use rsa method here.

[zhjc@slave5 ~] # ssh-keygen-t rsa-P "" [zhjc@slave5 ~] # cd ~ / .ssh [zhjc@slave5 ~] # chmod 777 ~ / .ssh [zhjc@slave5 .ssh] # cat id_rsa.pub > > authorized_ Keys [zhjc @ slave5 .ssh] # chmod 600 authorized_keys / / centos system requires this permission

Test whether the local login is secret-free:

[zhjc@slave5 ~] # ssh slave5

Configure master without password to log in to slave5:

Enter a command from the mater host to copy a copy of the public key to home

[zhjc@master ~] # cp .ssh / id_rsa.pub ~ / id_rsa_master.pub

Copy the id_rsa_master.pub in the home directory of master to the home of slave5

Enter the commands in the home directory of slave5:

[zhjc@slave5 ~] # cat id_rsa_master.pub > > .ssh / authorized_keys

The above are the details of learning the basic configuration of Linux system, user authorization, ssh secret-free login operation, please pay attention to other related articles!

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