Terms
Central control machine
The machine where OBD is installed. It is used to manage the OceanBase cluster, store the OceanBase cluster installation packages, and the cluster configuration information.
Target machine
The machine where OceanBase Database is installed.
Procedure
Follow these steps on the central control machine to set up passwordless SSH login. After configuration, you can log in to the target machine from the central control machine without a password.
Note
Passwordless login must be configured for the user you plan to use. If you plan to deploy OceanBase Database using the admin user, configure passwordless login for the admin user on the target machine. It is recommended to use the admin user to deploy OceanBase Database.
Run the following command on the central control machine to check if a key exists:
[admin@test001 ~]$ ls ~/.ssh/id_rsa.pubIf the result shows that a key already exists, there is no need to generate a new one.
(Optional) Run the following command on the central control machine to generate an SSH public and private key:
[admin@test001 ~]$ ssh-keygen -t rsaCopy the public key from the central control machine to the
authorized_keysfile on the target machine:[admin@test001 ~]$ ssh-copy-id -i ~/.ssh/id_rsa.pub <user>@<server_ip>
(Appendix) Script reference
When multiple target machines use the same login password, it is recommended that you use the following script on the central control machine to configure SSH passwordless login for multiple target machines.
Notice
You must have sudo privileges to execute the following script.
You must replace the SERVERS list and PASSWORD in the first two lines of the script with your actual machine list and password.
#!/usr/bin/bash
SERVERS=("<user>@<server_ip1>" "<user>@<server_ip2>" "<user>@<server_ip3>")
PASSWORD="******"
keygen() {
sudo yum -y install expect
expect -c "
spawn ssh-keygen -t rsa
expect {
*(~/.ssh/id_rsa):* { send -- \r;exp_continue}
*(y/n)* { send -- y\r;exp_continue}
*Enter* { send -- \r;exp_continue}
*(y/n)* { send -- y\r;exp_continue}
*Enter* { send -- \r;exp_continue}
eof {exit 0}
}
expect eof
"
}
copy(){
expect -c "
set timeout -1
spawn ssh-copy-id $1
expect {
*(yes/no)* { send -- yes\r; exp_continue }
*password:* { send -- $PASSWORD\r; exp_continue}
eof {exit 0}
}
expect eof
"
}
ssh_copy_id_to_all(){
keygen ;
for host in ${SERVERS[@]}
do
copy $host
done
}
ssh_copy_id_to_all
