Download Vagrant insecure private key if necessary
Rather than expecting the user to download the Vagrant insecure private key and put it into the appropriate directory, the script downloads the key if it's not already there. This patch also adds a README.rst. It explains the purpose of the directory which may also be used to cache the matching public key (used inside the VMs). Partial-Bug: 1312764 Implements: blueprint openstack-training-labs Change-Id: If0ee801f6f581230304ad5899b381680bce9154e
This commit is contained in:
parent
f2e5e3bb10
commit
25ea14bdcc
labs/lib
@ -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