SSH login password-free configuration between multiple machines in a cluster

SSH login password-free configuration between multiple machines in a cluster


 

Problem Description

Now that most of the projects from the traditional single machine deployment, slowly transformed into clusters to deploy multiple machines.

However, this involves the SSH password-free exchange between the machine problems.

When comparing the number of clusters machine when and how to quickly configure simple password-free logon between the machines do?


 

Perfect solution

1, respectively, on the view the cluster of machines, whether or not installed SSH, and service uptime

ps -ef | grep  ssh

 

2, step 1 to check if confirmed that no SSH installed, the following command can install SSH

sudo apt-get install ssh

Find the hidden directory .ssh (LL -a can view hidden files and hidden directories). Without this directory, you can use the command mkdir .ssh New.

 

3, into the .ssh directory, in each machine performs the following command (all the way round, generates a key):

ssh-keygen -t  rsa

 

4, after the completion of Step 3 will produce two files:

RSA-ID ( private key )

id-rsa.pub   ( public key )

 

5. Run the following commands in the first directory .ssh machine (hereinafter appear .ssh authorized_keys file directory)

cat id-rsa.pub >> authorized_keys

 

6, the copying machine of the first .ssh authorized_keys file directory to the directory .ssh the second computer

scp authorized_keys root@node2:/root/.ssh/

 

7, the second log machines, .ssh directory in the second machine, run the following command (the public key of the second machine is added to the authorized_keys in)

cat id-rsa.pub >> authorized_keys.

 

8, and so on, until the last public key cluster machine added to the authorized_keys.

 

9, after the last machine in the cluster after executing the additional generated authorized_keys file contains the public key of all the machines in the cluster.

At this point, the authorized_keys file on the last machine were copied to scp .ssh directory cluster each machine, overwriting the original authorized_keys file.

 

10, after the completion of Step 9, between a cluster of machines to achieve a password-free ssh login.

Guess you like

Origin www.cnblogs.com/miracle-luna/p/11809759.html