On Wed, Jul 01, 2015 at 05:25:03PM +0200, 'Helga Velroyen' via ganeti-devel
wrote:
This patch extends the SSH handling by creating the .ssh
directory when generating SSH keys if it did not exist
yet. This fixes Issue 1103.
Signed-off-by: Helga Velroyen <[email protected]>
---
lib/ssh.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/lib/ssh.py b/lib/ssh.py
index 4514b5e..efee389 100644
--- a/lib/ssh.py
+++ b/lib/ssh.py
@@ -48,6 +48,7 @@ from ganeti import vcluster
from ganeti import compat
from ganeti import serializer
from ganeti import ssconf
+from ganeti import runtime
def GetUserFiles(user, mkdir=False, dircheck=True, kind=constants.SSHK_DSA,
@@ -694,6 +695,12 @@ def InitSSHSetup(error_fn=errors.OpPrereqError,
_homedir_fn=None,
utils.CreateBackup(name)
utils.RemoveFile(name)
+ ssh_dir = utils.PathJoin(_homedir_fn(constants.SSH_LOGIN_USER), ".ssh")
+ if not os.path.exists(ssh_dir):
+ getent = runtime.GetEnts()
+ utils.MakeDirWithPerm(ssh_dir, "700", getent.noded_uid,
+ getent.noded_gid)
Function GetUserFiles that is called just at the beginning of InitSSHSetup
has an keyword argument "mkdir" that does just that. There is a slight
difference though, it seems that GetUserFiles doesn't ensure the proper
owner. So perhaps adding mkdir=True above instead would suffice? And check,
if it might be necessary to update the owner/group and if so, add it to
GetUserFiles?
Thanks!
Petr
+
result = utils.RunCmd(["ssh-keygen", "-t", "dsa",
"-f", new_priv_key_name,
"-q", "-N", ""])
--
2.4.3.573.g4eafbef