Search This Blog

Sunday, 14 February 2021

Linux Shell script to copy ssh keys to multiple remote servers

 1) Shell Script to copy ssh keys to remote Servers



#!/bin/ksh


echo "Enter your password: "
stty -echo
read -s SSHPASS
export SSHPASS
stty echo
for host in `cat host.txt`
do

sshpass -e ssh-copy-id -f ${host} -o StrictHostKeyChecking=no

done
SSHPASS=""



List the hostnames in host.txt file

cat>host.txt
host1
host2
host3
host4




No comments: