]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
ceph-daemon: create ~/.ssh if not exist
authorKefu Chai <kchai@redhat.com>
Fri, 1 Nov 2019 09:39:35 +0000 (17:39 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 1 Nov 2019 13:33:25 +0000 (21:33 +0800)
there is chance that /root/.ssh does not exist yet, when we are trying
to add key to authorized_keys.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/ceph-daemon

index a5c708e9655813e98e976e84945a83989648f729..71cd85f9547b7d88b1227f0b4e1d15dc1c871b7d 100755 (executable)
@@ -1062,6 +1062,8 @@ def command_bootstrap():
         ).run()
 
         logger.info('Adding key to root@localhost\'s authorized_keys...')
+        if not os.path.exists('/root/.ssh'):
+            os.mkdir('/root/.ssh', mode=0o700)
         with open('/root/.ssh/authorized_keys', 'a') as f:
             os.fchmod(f.fileno(), 0o600)  # just in case we created it
             f.write(ssh_pub.strip() + '\n')