From 81dab9c1476e2e26880adb3c31096696c7485f79 Mon Sep 17 00:00:00 2001 From: Anders Ingemann Date: Mon, 20 Jan 2014 21:14:01 +0100 Subject: [PATCH] Set proper permissions on ~vagrant/.ssh --- plugins/vagrant/tasks.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/vagrant/tasks.py b/plugins/vagrant/tasks.py index fccbce6..c8076bc 100644 --- a/plugins/vagrant/tasks.py +++ b/plugins/vagrant/tasks.py @@ -93,6 +93,16 @@ class AddInsecurePublicKey(Task): with open(authorized_keys_path, 'a') as authorized_keys: authorized_keys.write(insecure_public_key) + import stat + os.chmod(ssh_dir, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) + os.chmod(authorized_keys_path, stat.S_IRUSR | stat.S_IWUSR) + + # We can't do this directly with python, since getpwnam gets its info from the host + from common.tools import log_check_call + log_check_call(['/usr/sbin/chroot', info.root, + '/bin/chown', 'vagrant:vagrant', + '/home/vagrant/.ssh', '/home/vagrant/.ssh/authorized_keys']) + class SetRootPassword(Task): description = 'Setting the root password to `vagrant\''