Copying an ssh-key to multiple servers logins using shell script I am setting up SSH keys on my servers and I am trying to write a script to copy them all out Basically what I want to do is copy the ssh id from server 1 to server 1-10, then log into server 2 and copy the ssh id from server 2 to server 1-10
bash script to ssh multiple servers in a Loop and issue commands I'm trying to read the server one by one from the file, SSH in the server and execute ls to see the directory contents My loop runs just once when I run the SSH command, however, for SCP it runs for all servers in the text file and exits, I want the loop to run till the end of text file for SSH
ssh-copy-id Command: Copy SSH Keys to a Remote Server - Linuxize ssh-copy-id is a utility that copies your local SSH public key to a remote server’s authorized_keys file This sets up key-based authentication, allowing you to log in without entering a password
Bash SSH Script: Run Commands on Multiple Servers - GoLinuxCloud To run one command across multiple servers, read the hosts file with while read, use ssh -n so SSH does not read from the same stdin as the hosts loop, and enable BatchMode=yes so authentication failures do not wait for user input
Automating ssh-copy-id | Baeldung on Linux Here, my_secret_password is the password of alice on host2 ssh-copy-id doesn’t ask for the password during the configuration, therefore, it’s possible to use ssh-copy-id in a script for the configuration of ssh for many hosts
ssh - better way to loop through a list of servers - Server Fault To execute a simple task across a wide range of servers without using any tool designed for this purpose, regardless they require previous infrastructure or not, you can use a simple shell script called mussh, distributed as a package in many distributions