Skip to content

Instantly share code, notes, and snippets.

@mamedshahmaliyev
Last active October 15, 2019 17:51
Show Gist options
  • Save mamedshahmaliyev/72129dd2b78dd4f9c08d3689377d1fff to your computer and use it in GitHub Desktop.
Save mamedshahmaliyev/72129dd2b78dd4f9c08d3689377d1fff to your computer and use it in GitHub Desktop.
create ssh key pair silently using ssh-keygen without prompt and ssh-copy-id to multiple hosts
# generate ssy key pair silently
yes y | ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa > /dev/null
# register public key in multiple hosts
for ip in "192.168.0.1" "192.168.0.2"; do sshpass -p 'toor' ssh-copy-id -oStrictHostKeyChecking=no "root@$ip" > /dev/null; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment