Implementation of Multi-Server Deployment Script

Deployment becomes a problem when the game has a large number of open servers. Today, I briefly studied the distribution and deployment mode using ssh-keygen+scp, and made a simple record of the key parts.

1. About ssh-keygen
ssh is a protocol designed to provide security for remote login sessions and other network services. By default, the ssh link requires password authentication. It can be modified by adding system authentication (that is, public-private key). After the modification, switching between systems can avoid password input and ssh authentication.
ssh-keygen is used to generate, manage and convert authentication keys for ssh, including RSA and DSA keys.

2. Operation process (the server where the internal network source code is located is called the jump machine; the external network server is called the server)
1. Execute ssh-keygen on the jump machine to generate id_rsa and id_rsa.pub

cd ~/.ssh/
ssh-keygen

It's OK to go back to the car all the way!

2. Create (or generate) the .ssh directory corresponding to the user on the server
ssh [email protected] mkdir ~/.ssh


3. Upload id_rsa.pub to the server and rename it to authorized_keys
scp ~/.ssh/id_rsa.pub   [email protected]:~/.ssh/authorized_keys


4. Modify the authorized_keys permission on the server to 400
ssh [email protected] chmod 400 ~/.ssh/authorized_keys


5. Modify the id_rsa permission on the jump machine to 400
chmod 400 ~/.ssh/id_rsa


6. Try to log in and add the scp distribution script.

In fact, it is the same operation as the third step. Because the key is used to log in, the scp process will not be disrupted by entering the password.

For later updates, you can ssh to the corresponding server for backup, decompression, overwrite, restart, etc. after scp is completed!

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326926550&siteId=291194637