-
Generate ssh keys on source host with
ssh-keygen
; -
Disable known_hosts prompt(optional): add "StrictHostKeyChecking no" into ~/.ssh/config;
-
Run fabric script to distribute pubkey, you have to input password manually:
fab distkey
;
$ cat fabfile.py from fabric.api import local, task env.hosts = ['10.0.2.48', '10.0.2.49', '10.0.7.141', '10.0.7.142', '10.0.7.143'] @task def distkey(): env.user = 'gcp' local('ssh-copy-id %(user)s@%(host)s' % env)
You have to input password for every host. So try to use uniform password for all hosts. It will save you lots of times.