For personal use, and all, I’ve created this script to make my job sometimes easy. I have multiple servers and i didnt want to write every time same command for every server, and because of that, i created this script. All my project’s are on my GitHub account and here is link where you can look for this repository: SSH-KEY-SERVER-ADD.
Script that adds multiple SSH keys to multiple servers.
To download this script, click THIS LINK or follow the commands below.
To download it from the server, if you did not download it from the browser, you must enter the following command.
wget https://github.com/tomeksdev/ssh-key-server-add/releases/download/v1.0.0/import-ssh-keys.tar.gz
OR
git clone https://github.com/tomeksdev/ssh-key-server-add.git
If you downloaded from a browser or with the wget
command, you need to unpack the downloaded file with the following command. If you are working with git, you can skip this step.
tar -xvf archive.tar.gz
Once the file is unzipped or cloned with Git, we only need to do two things to make the script work. First, we need to add an executable right to the import_ssh.sh
file, which we can then run.
chmod +x import_ssh.sh
Secondly, we need to fill or modify the Server.txt
and Keys.txt
configuration files:
Add multiple servers with root@ip_address. Each server in a new line.
Add or change keys if necessary. Also each ssh key in a new line.
And last but not least run the script:
sh import_ssh.sh
OR
./import_ssh.sh