github.com/annchain/OG@v0.0.9/scripts/deploy/batch_sshcopyid.py (about) 1 import subprocess 2 3 from common import hosts 4 5 SSH_PASSWORD_FILE = 'data/passwd' 6 SSH_HOSTS_FILE = 'data/hosts' 7 SSH_USERNAME = 'admin' 8 9 if __name__ == '__main__': 10 hs = hosts.hosts(SSH_HOSTS_FILE) 11 12 pattern = 'sshpass -f %s ssh-copy-id -o StrictHostKeyChecking=no %s@%s' 13 for h in hs: 14 p = pattern % (SSH_PASSWORD_FILE, SSH_USERNAME, h) 15 print(p) 16 print(subprocess.run(p, shell=True, check=True))