labs: check and fix private ssh key permissions
If a user changes the permissions of the Vagrant insecure ssh key, ssh authentication doesn't work anymore and they are prompted for a password. To prevent that, check (and adjust, if necessary) file permissions before using ssh. Change-Id: I90589553de30ef606c4083a1b9980c2cc80a3b3b
This commit is contained in:
parent
b5d209f515
commit
6f44c8b272
@ -44,10 +44,15 @@ function check_vagrant_private_key {
|
|||||||
local key_name="vagrant"
|
local key_name="vagrant"
|
||||||
local key_url=https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/$key_name
|
local key_url=https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/$key_name
|
||||||
local vagrant_key_dir=$LIB_DIR/vagrant-ssh-keys
|
local vagrant_key_dir=$LIB_DIR/vagrant-ssh-keys
|
||||||
|
local vagrant_key_path=$vagrant_key_dir/$key_name
|
||||||
|
|
||||||
if [ ! -f "$vagrant_key_dir/$key_name" ]; then
|
if [ ! -f "$vagrant_key_path" ]; then
|
||||||
download "$key_url" "$vagrant_key_dir" $key_name
|
download "$key_url" "$vagrant_key_dir" $key_name
|
||||||
chmod 400 "$vagrant_key_dir/$key_name"
|
fi
|
||||||
|
|
||||||
|
if ! ls -l "$vagrant_key_path"|grep -q "^-r--------"; then
|
||||||
|
echo "Adjusting permissions for $vagrant_key_path"
|
||||||
|
chmod 400 "$vagrant_key_path"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user