first add

This commit is contained in:
Your Name
2024-08-02 14:44:39 +08:00
parent 0b0edc3755
commit 968bc3dd24
35 changed files with 3693 additions and 65 deletions

25
setup_ssh.sh Normal file
View File

@@ -0,0 +1,25 @@
#!/bin/bash
# 定义主机列表
hosts=("10.200.1.10" "10.200.1.11" "10.200.1.12")
# 当前主机的用户名
user="root"
# 检查ssh-keygen是否已经生成密钥对
if [ ! -f ~/.ssh/id_rsa ]; then
echo "生成SSH密钥对..."
ssh-keygen -t rsa -b 4096 -N "" -f ~/.ssh/id_rsa
else
echo "SSH密钥对已经存在..."
fi
# 分发公钥到其他主机
for host in "${hosts[@]}"; do
if [ "$host" != "$(hostname -I | awk '{print $1}')" ]; then
echo "将公钥复制到$host..."
ssh-copy-id -i ~/.ssh/id_rsa.pub "$user@$host"
fi
done
echo "密钥认证配置完成。"