- dot_ssh = '/home/%s/.ssh' % self.name
- def do_installation():
- if not os.access(dot_ssh, os.F_OK): os.mkdir(dot_ssh)
- os.chmod(dot_ssh, 0700)
- tools.write_file(dot_ssh + '/authorized_keys', lambda f: f.write(new_keys))
- logger.log('%s: installing ssh keys' % self.name)
- tools.fork_as(self.name, do_installation)
+ gid = grp.getgrnam("slices")[2]
+ pw_info = pwd.getpwnam(self.name)
+ uid = pw_info[2]
+ pw_dir = pw_info[5]
+
+ dot_ssh = pw_dir + '/.ssh'
+ if not os.access(dot_ssh, os.F_OK): os.mkdir(dot_ssh)
+
+ auth_keys = dot_ssh + '/authorized_keys'
+ tools.write_file(auth_keys, lambda f: f.write(new_keys))
+
+ os.chmod(dot_ssh, 0700)
+ os.chmod(auth_keys, 0600)
+
+ os.chown(dot_ssh, uid, gid)
+ os.chown(auth_keys, uid, gid)
+
+ logger.log('%s: installed ssh keys' % self.name)