配置SSH互信

分享一段配置SSH互信的脚本。

-- all 3 nodes

su - mysql
mkdir -p $HOME/.ssh
chmod 700 $HOME/.ssh
ssh-keygen -t rsa -P '' -f $HOME/.ssh/id_rsa
cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys
chmod 644 $HOME/.ssh/authorized_keys

--Copy the public key to new slave node in mysql user $HOME directory
--node1

scp $HOME/.ssh/id_rsa.pub [email protected]:/home/mysql/.ssh/id_rsa.pub_node1
scp $HOME/.ssh/id_rsa.pub [email protected]:/home/mysql/.ssh/id_rsa.pub_node1

--node2

scp $HOME/.ssh/id_rsa.pub [email protected]:/home/mysql/.ssh/id_rsa.pub_node2
scp $HOME/.ssh/id_rsa.pub [email protected]:/home/mysql/.ssh/id_rsa.pub_node2

--node3

scp $HOME/.ssh/id_rsa.pub [email protected]:/home/mysql/.ssh/id_rsa.pub_node3
scp $HOME/.ssh/id_rsa.pub [email protected]:/home/mysql/.ssh/id_rsa.pub_node3

--node1

cat $HOME/.ssh/id_rsa.pub_node2 >> $HOME/.ssh/authorized_keys
cat $HOME/.ssh/id_rsa.pub_node3 >> $HOME/.ssh/authorized_keys

--node2

cat $HOME/.ssh/id_rsa.pub_node1 >> $HOME/.ssh/authorized_keys
cat $HOME/.ssh/id_rsa.pub_node3 >> $HOME/.ssh/authorized_keys

--node3

cat $HOME/.ssh/id_rsa.pub_node1 >> $HOME/.ssh/authorized_keys
cat $HOME/.ssh/id_rsa.pub_node2 >> $HOME/.ssh/authorized_keys

--modify /etc/ssh/ssh_config文件(或$HOME/.ssh/config)in all 3 nodes

su - 
vi /etc/ssh/ssh_config

StrictHostKeyChecking no
UserKnownHostsFile /dev/null

systemctl restart sshd.service

--copy something from local to remote.

[mysql@node1 ~]$ scp -r /opt/soft/mysql-cluster-8.0.25-el7-x86_64 node2:/opt/soft
[mysql@node1 ~]$ scp -r /opt/soft/mysql-cluster-8.0.25-el7-x86_64 node3:/opt/soft

你可能感兴趣的:(linux)