Skip to content

Instantly share code, notes, and snippets.

@garaemon
Created March 21, 2022 03:34
Show Gist options
  • Save garaemon/1d587b9d0bae7486846891f8b8fb53ce to your computer and use it in GitHub Desktop.
Save garaemon/1d587b9d0bae7486846891f8b8fb53ce to your computer and use it in GitHub Desktop.
function ssh-with-copy-id() {
ssh -o "PasswordAuthentication=no" $@
if [ $? != "0" ]; then
echo "Failed to ssh w/o password. Copy id_rsa.pub to the machine."
ssh-copy-id $@
ssh -o "PasswordAuthentication=no" $@
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment