Created
December 11, 2019 23:44
-
-
Save aniongithub/182a0e2eba06014bfb6a6addc90fbe12 to your computer and use it in GitHub Desktop.
docker-machine create script for any machine you can ssh into
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# To invoke with named arguments, use | |
# https://unix.stackexchange.com/a/129394/358706 | |
REMOTE_USER="user" | |
REMOTE_EMAIL="[email protected]" | |
REMOTE_HOSTNAME="hostname_here" | |
REMOTE_KEYNAME="${REMOTE_HOSTNAME}.id.rsa" | |
REMOTE_IPADDRESS=`dig +short $REMOTE_HOSTNAME` | |
pushd ~/.ssh | |
ssh-keygen -t rsa -b 4096 -C "$REMOTE_EMAIL" -f "$REMOTE_KEYNAME" | |
ssh-copy-id -i "$REMOTE_KEYNAME" "$REMOTE_USER@$REMOTE_IPADDRESS" | |
docker-machine create \ | |
--driver generic \ | |
--generic-ip-address="$REMOTE_IPADDRESS" \ | |
--generic-ssh-user="$REMOTE_USER" \ | |
--generic-ssh-key "$REMOTE_KEYNAME" \ | |
$REMOTE_HOSTNAME | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment