Created
April 13, 2019 10:30
-
-
Save aliva/3c452c30d45e29389db53edb6909c199 to your computer and use it in GitHub Desktop.
add ssh key to authorized_keys in all servers (give access to all server for a new key)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# create a file named key which contains the public key for new user | |
export SERVERS="ip1 ip2 ip3" | |
for server in $SERVERS | |
do | |
echo "=============" | |
echo $server | |
ssh $server "hostname" | |
cat key | ssh ${server} "tee -a ~/.ssh/authorized_keys" | |
done |
@vahit I already have access to server with my ssh key, This scripts simply connects to those servers and gives access to second person
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use as
ssh-copy-id -i /paht/to/key/file ${server}