22 lines
456 B
Bash
22 lines
456 B
Bash
#!/bin/bash
|
||
|
||
# 新的服务器列表
|
||
servers=(
|
||
"39.100.87.238"
|
||
"39.100.84.78"
|
||
"47.92.213.251"
|
||
"39.100.86.136"
|
||
)
|
||
|
||
# 本地SSH公钥路径
|
||
local_public_key="$HOME/.ssh/id_rsa.pub"
|
||
|
||
# 远程主机用户名
|
||
remote_user="root"
|
||
|
||
# 循环遍历服务器
|
||
for server in "${servers[@]}"; do
|
||
# 使用sshpass将密码传递给ssh-copy-id,并将公钥追加到服务器
|
||
sshpass -p "Royroiy123" yes | ssh-copy-id -i "$local_public_key" "$remote_user@$server"
|
||
done
|