ssh密钥
parent
9ca1dc46e7
commit
dd71d4628d
|
|
@ -1,16 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
# 新增服务器列表
|
||||
servers=("49.232.223.191" "49.233.162.49" "192.144.200.59" "81.70.101.153")
|
||||
# 新的服务器列表
|
||||
servers=(
|
||||
"39.100.87.238"
|
||||
"39.100.84.78"
|
||||
"47.92.213.251"
|
||||
"39.100.86.136"
|
||||
)
|
||||
|
||||
# 本地计算机的SSH公钥路径
|
||||
# 本地SSH公钥路径
|
||||
local_public_key="$HOME/.ssh/id_rsa.pub"
|
||||
|
||||
# 远程主机的用户名和密码
|
||||
# 远程主机用户名
|
||||
remote_user="root"
|
||||
remote_password="YfP}(k65Wn38Fe?%"
|
||||
|
||||
# 循环遍历服务器
|
||||
for server in "${servers[@]}"; do
|
||||
# 使用sshpass命令将密码传递给ssh-copy-id,并将公钥追加到服务器
|
||||
sshpass -p "$remote_password" yes|ssh-copy-id -i "$local_public_key" "$remote_user@$server"
|
||||
# 使用sshpass将密码传递给ssh-copy-id,并将公钥追加到服务器
|
||||
sshpass -p "Royroiy123" yes | ssh-copy-id -i "$local_public_key" "$remote_user@$server"
|
||||
done
|
||||
Loading…
Reference in New Issue