To simplify the management of a group of computer we can use several linux tools.
1 Setting trusted authentication
You can login to a remote Linux server without entering password.
This section demonstrate how to do login from local-host to remote-host as user username without password.
In trusted environment we use the SSH keys to avoid put the password when connect via SSH.
Generate the pair private/public keys using ssh-key-gen on local-host.
Copy
su - username
Copy
ssh-keygen
Copy the public key to remote-host using ssh-copy-id.
Copy
ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host
Now try logging into the machine, with ssh remote-host
Copy
ssh remote-host
SSH did not ask for password.
2 Using parallell ssh
First install the epel-release repository to have the pssh package available.
Copy
yum install epel-release
Install the package pssh
Copy
yum install pssh
-
Create a list of username@hostname in a file we name "grid.txt" like:
Copy
nuc00 nuc01 nuc02 nuc03 nuc04 nuc05 nuc06 nuc07 nuc08 nuc09 nuc10
-
Use pssh to run a command on the grid.
Copy
$ pssh -h grid.txt -l informix -A -i "date" Password: [PRESS ENTER TO VALIDATE USING SSH KEY]
[1] 11:26:56 [SUCCESS] nuc01 Thu Nov 22 11:26:56 CET 2018 [2] 11:26:56 [SUCCESS] nuc02 Thu Nov 22 11:26:56 CET 2018 [3] 11:26:56 [SUCCESS] nuc05 Thu Nov 22 19:28:57 CET 2018 [4] 11:26:56 [SUCCESS] nuc03 Thu Nov 22 11:26:56 CET 2018 [5] 11:26:56 [SUCCESS] nuc06 Thu Nov 22 11:26:56 CET 2018 [6] 11:26:56 [SUCCESS] nuc08 Thu Nov 22 11:26:56 CET 2018 [7] 11:26:56 [SUCCESS] nuc04 Thu Nov 22 11:26:56 CET 2018 [8] 11:26:56 [SUCCESS] nuc09 Thu Nov 22 11:26:56 CET 2018 [9] 11:26:56 [SUCCESS] nuc00 Thu Nov 22 11:26:56 CET 2018 [10] 11:26:56 [SUCCESS] nuc07 Thu Nov 22 11:26:56 CET 2018 [11] 11:26:57 [SUCCESS] nuc10 Thu Nov 22 19:26:09 CET 2018
-
Create a user account on all machines:
Copy
$ pssh -h grid.txt -l root -A -i "useradd hadoop" Password: [PRESS ENTER TO VALIDATE USING SSH KEY]
[2] 18:16:05 [SUCCESS] nuc08 [2] 18:16:05 [SUCCESS] nuc09 [3] 18:16:05 [SUCCESS] nuc01 [4] 18:16:05 [SUCCESS] nuc02 [5] 18:16:05 [SUCCESS] nuc03 [6] 18:16:05 [SUCCESS] nuc07 [7] 18:16:05 [SUCCESS] nuc05 [8] 18:16:05 [SUCCESS] nuc06 [9] 18:16:05 [SUCCESS] nuc04 [10] 18:16:05 [SUCCESS] nuc10 [11] 18:16:05 [SUCCESS] nuc00
- Modify the user password on all machines:
Copy
$ pssh -h grid.txt -l root -A -i "echo 'hadoop' | passwd --stdin hadoop" Password: [PRESS ENTER TO VALIDATE USING SSH KEY]
[1] 18:19:10 [SUCCESS] nuc08 passwd: all authentication tokens updated successfully. [2] 18:19:10 [SUCCESS] nuc00 Changing password for user hadoop. passwd: all authentication tokens updated successfully. [3] 18:19:10 [SUCCESS] nuc02 Changing password for user hadoop. passwd: all authentication tokens updated successfully. [4] 18:19:10 [SUCCESS] nuc05 Changing password for user hadoop. passwd: all authentication tokens updated successfully. [5] 18:19:10 [SUCCESS] nuc01 Changing password for user hadoop. passwd: all authentication tokens updated successfully. [6] 18:19:10 [SUCCESS] nuc04 Changing password for user hadoop. passwd: all authentication tokens updated successfully. [7] 18:19:10 [SUCCESS] nuc03 Changing password for user hadoop. passwd: all authentication tokens updated successfully. [8] 18:19:10 [SUCCESS] nuc09 Changing password for user hadoop. passwd: all authentication tokens updated successfully. [9] 18:19:10 [SUCCESS] nuc07 Changing password for user hadoop. passwd: all authentication tokens updated successfully. [10] 18:19:10 [SUCCESS] nuc06 Changing password for user hadoop. passwd: all authentication tokens updated successfully. [11] 18:19:10 [SUCCESS] nuc10 Changing password for user hadoop. passwd: all authentication tokens updated successfully.