Because the project is computationally large , the task needs to be distributed across multiple computers , because it is not familiar to the distributed concept , I think of the Linux The simplest ssh protocol , remote control of other computers , and then write the shell The script runs the program on all computers uniformly . ( my operating system is Ubuntu16.04)
First, enter the following command on the respective computer to see if ssh is installed
Ps-e | grep ssh
If the results are returned by the sshd in, then the SSH is already installed , Otherwise the line is installed .
sudo apt-get install SSH installation .
Next we use ssh to log on to other computers , SSH [email protected] login , will be prompted to enter a password . you can remotely control another computer by entering a password .
(ifconfig view IP)
If you have 10 computers that require you to connect and assign Tasks , it is necessary to remember the corresponding computer IP and password every time. It's not good for us to run the script uniformly , so the first step is to have a computer that requires remote control to be password-free .
First we generate a key on your own computer .
Ssh-keygen, and then all the way to enter, This will generate the . SSH folder in the home directory
Ls-a ( see if the . SSH folder is generated )
Enter the . SSH folder to view the file
This indicates that the key pair has been generated . Next, pass the public key through SCP Copy to the computer you need to connect to .
Cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
SCP ~/.ssh/id_rsa.pub username@IP: ~/.ssh/id_rsa.pub_Copy
Next you need to connect to the computer as a server on the remote connection
Touch ~/.ssh/authorized_keys
Cat ~/.ssh/id_rsa.pub_copy >> ~/.ssh/authorized_keys
This is the last step , Modify Permissions
chmod 755 ~
chmod ~/.ssh
chmod ~/.ssh/authorized_keys
Many people here do not quite understand the meaning of 755,700,600 These data , This is the number of Linux permissions to express the way .
Let us explain , For example, when we look at the permissions of a file
We'll see the results above.,This part of the front is made up of 10 bits, 1-3-3-3the way,The first letter indicates the type of file, DThat means the folder.Documentthe first letter,next the first three bits represents the owner's permissions,the second three-bit is the permission of the same group,the third three-bit is the permission of the other group. r--Read, WWrite, X-Execution,sorwxrepresents the current group readable writable executable.back to the numbers above, Ralso corresponds to the number4,wcorresponding2,xcorresponding1.Now you can understand755indicates that the owner is a readable writable executable,Group is writable executable,other groups are also writable executables.
Ok , Now you can test if you can password-free login to other people's computers .
During the run, You may encounter this problem , which is to indicate that ssh-agent is running , However, we cannot find the corresponding key, we can solve it through ssh-add , and also through Ssh-add-l to see the attached key.
In a remote connection, you still need to enter the user name and IP, and if you do not want to enter the user name , Create an identical user for all the computers initially .
Script runs All Programs
SCREEN-DM ssh-t [email protected] "..." ( Enter the command you want to run in quotation marks )
SCREEN-DM ssh-t [email protected] "..."
PS: Well-written place I hope you have a lot of advice.
A summary of the Linux command ssh