Skip to content

Instantly share code, notes, and snippets.

@wangshijun
Created September 19, 2012 07:42
Show Gist options
  • Save wangshijun/3748233 to your computer and use it in GitHub Desktop.
Save wangshijun/3748233 to your computer and use it in GitHub Desktop.
shell: build trust relations between linux hosts
#!/bin/bash
# build trust relations between linux hosts
user="wangshijun"
machine="hostname1 hostname2 hostname3"
for i in $machine
do
scp ~/.ssh/id_rsa.pub ${user}@$i:./
ssh ${user}@$i 'cat id_rsa.pub >>.ssh/authorized_keys; chmod 700 .ssh;chmod 600 .ssh/authorized_keys'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment