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

Beginners in cloud computing need to pay attention to what to do with multi-server batches.

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

What do you need to pay attention to for beginners in cloud computing? How to operate multi-server batches? In the daily work of cloud computing operators, it is usually necessary to execute the same commands on multiple servers at the same time, such as comparing logs, checking services, etc., which requires practitioners to have the ability to operate servers in batches. Many beginners of cloud computing don't know how to use Linux Shell to operate in batches on multiple servers, so let's take a look at it.

If you need to perform the same operation on a large number of servers, or when deploying distributed applications (elk, K8s, geth, etc.), the general practice is to write a local script for batch operations, CSP to each server in turn, and then SSH to each server to execute the script. The following is an introduction of relevant knowledge points:

SSH

SSH realizes the connection between SSH client and server by establishing a secure tunnel in the network.

Public key login

After understanding the principle of asymmetric encryption, it is very easy to log in with the public key. Because the public and private keys are the only pair, in the case that the client ensures the security of its own private key, the server can completely determine the authenticity of the client through the public key, so in order to achieve the public key login, we need to become a public-private key pair. Key pairs are generated through the ssh-keygen command, and to make the steps more complete, I temporarily save them to the working directory, which is saved to the /. Ssh directory by default.

Put the contents of the private key file. / test into the client's ~ /. Ssh/id_rsa, and then try to log in to the server with a password, and put the contents of the public key content. / test.pub into the server's ~ /. Ssh/authorized_keys. When logging in again, ssh will automatically use its own private key to authenticate, thus avoiding the output of the password.

Batch operation

Public key login helps us avoid the trouble of outputting passwords every time we log in to the server, and it also solves the problem that every login session is blocked synchronously, so that we can use the ssh user@host command mode of ssh to execute commands directly on the server.

At the same time, when we have an ip list, it is possible to loop through the ip list using for to execute commands in batches on multiple servers.

To learn more about Linux Shell scripting and to quickly grasp the skills needed by cloud computing operation and maintenance engineers, you can choose a professional study to get started in the cloud computing industry.

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