Set up passwordless SSH
We can set up passwordless SSH so that we only need issue configuration commands on one node in the HA group.
To set up passwordless SSH you must configure the mqm id on each node, then
generate a key on each node for that user. You then distribute the keys to the other nodes, and test
the connection to add each node to the list of known hosts. Finally you lock down the
mqm id .Note: The instructions assume that you are defining an HA group with
separate primary, alternate, and replication interfaces, and you therefore define passwordless SSH
access over the primary and alternate interfaces. If you plan to configure a system with a single IP
address, then you define passwordless SSH access over that single interface.
Procedure
-
On each of the three nodes, complete the following steps to set up the mqm
user and generate an SSH key:
-
Change the mqm home directory to /home/mqm:
usermod -d /home/mqm mqm
-
Create the /home/mqm directory:
mkhomedir_helper mqm
-
Add the mqm password:
passwd mqm
-
Run the interactive shell as mqm:
su mqm
-
Generate the mqm authentication key:
ssh-keygen -t rsa -f /home/mqm/.ssh/id_rsa -N ''
-
Change the mqm home directory to /home/mqm:
-
On each of the three nodes, complete the following steps to add that node's key to the other
two nodes and test the connections for each nodes primary and (if used) alternate addresses:
-
Add the key to the remote nodes
ssh-copy-id -i /home/mqm/.ssh/id_rsa.pub remote_node1_primary_address ssh-copy-id -i /home/mqm/.ssh/id_rsa.pub remote_node1_alternate_address ssh-copy-id -i /home/mqm/.ssh/id_rsa.pub remote_node2_primary_address ssh-copy-id -i /home/mqm/.ssh/id_rsa.pub remote_node2_alternate_address
-
Check passwordless ssh and update known_hosts for remote nodes:
ssh remote_node1_primary_address uname -n ssh remote_node1_alternate_address uname -n ssh remote_node2_primary_address uname -n ssh remote_node2_alternate_address uname -n
For each connection, you are prompted to confirm to proceed. Confirm for each one to update the known_hosts. You must complete this before you attempt to configure the HA group using passwordless SSH. -
Exit the interactive shell as mqm:
exit
-
Add the key to the remote nodes
-
On each node, as root, complete the following steps to remove the mqm password
and lock the id:
-
Remove the mqm password:
passwd -d mqm
-
Lock mqm:
passwd -l mqm
-
Remove the mqm password:
-
On each node, as root, complete the following steps to set up sudo access for the
mqm user:
-
Change directory to /etc and edit the sudoers
file:
cd /etc vi sudoers
-
Search for the line "## Allows people in group wheel to run all commands" and
add the following text below the line:
#%mqm ALL=(ALL) ALL
-
Search for the line "## Same thing without a password" and add the following
text below the line:
%mqm ALL=(ALL) NOPASSWD: ALL
-
Change directory to /etc and edit the sudoers
file: