Merge "Download Vagrant insecure private key if necessary"
This commit is contained in:
commit
d287a8bb3f
@ -40,6 +40,19 @@ function get_base_disk_path {
|
||||
#-------------------------------------------------------------------------------
|
||||
# ssh
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# Download Vagrant insecure private key if necessary
|
||||
function check_vagrant_private_key {
|
||||
local KEY_NAME="vagrant"
|
||||
local KEY_URL=https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/$KEY_NAME
|
||||
local VAGRANT_KEY_DIR=$LIB_DIR/vagrant-ssh-keys
|
||||
|
||||
if [ ! -f "$VAGRANT_KEY_DIR/$KEY_NAME" ]; then
|
||||
download "$KEY_URL" "$VAGRANT_KEY_DIR" $KEY_NAME
|
||||
chmod 400 "$VAGRANT_KEY_DIR/$KEY_NAME"
|
||||
fi
|
||||
}
|
||||
|
||||
function strip_top_dir {
|
||||
local FULL_PATH=$1
|
||||
echo "${FULL_PATH/$TOP_DIR\//}"
|
||||
@ -49,6 +62,9 @@ function strip_top_dir {
|
||||
function vm_scp_to_vm {
|
||||
local SSH_PORT=$1
|
||||
shift
|
||||
|
||||
check_vagrant_private_key
|
||||
|
||||
while (($#)); do
|
||||
local SRC_PATH=$1
|
||||
shift
|
||||
@ -68,6 +84,9 @@ function vm_scp_to_vm {
|
||||
function vm_ssh {
|
||||
local SSH_PORT=$1
|
||||
shift
|
||||
|
||||
check_vagrant_private_key
|
||||
|
||||
ssh -q \
|
||||
-i "$LIB_DIR/vagrant-ssh-keys/vagrant" \
|
||||
-o "UserKnownHostsFile /dev/null" \
|
||||
|
4
labs/lib/vagrant-ssh-keys/README.rst
Normal file
4
labs/lib/vagrant-ssh-keys/README.rst
Normal file
@ -0,0 +1,4 @@
|
||||
This directory may contain cached copies of the insecure Vagrant keys from
|
||||
https://github.com/mitchellh/vagrant/tree/master/keys.
|
||||
|
||||
They allow ssh access to Vagrant VMs or (if enabled) osbash VMs.
|
Loading…
x
Reference in New Issue
Block a user