Ejemplo n.º 1
0
    def _prepareSshKeys(self, manager, temp_dir_path):
        key_path = None
        if self._sshKey is not None:
            ssh_key_data = yield manager.renderSecrets(self._sshKey)

            key_path = os.path.join(temp_dir_path, 'ssh-key')
            misc.writeLocalFile(key_path, ssh_key_data, mode=stat.S_IRUSR)

        known_hosts_path = None
        if self._sshHostKey is not None:
            ssh_host_key_data = yield manager.renderSecrets(self._sshHostKey)
            ssh_host_key_data = getSshKnownHostsContents(ssh_host_key_data)

            known_hosts_path = os.path.join(temp_dir_path, 'ssh-known-hosts')
            misc.writeLocalFile(known_hosts_path, ssh_host_key_data)

        defer.returnValue((key_path, known_hosts_path))
Ejemplo n.º 2
0
 def _downloadSshKnownHosts(self, path):
     writeLocalFile(path, getSshKnownHostsContents(self.sshHostKey))
Ejemplo n.º 3
0
 def _downloadSshPrivateKey(self, keyPath):
     # We change the permissions of the key file to be user-readable only so
     # that ssh does not complain. This is not used for security because the
     # parent directory will have proper permissions.
     writeLocalFile(keyPath, self.sshPrivateKey, mode=stat.S_IRUSR)
Ejemplo n.º 4
0
 def _downloadSshKnownHosts(self, path):
     if self.sshKnownHosts is not None:
         contents = self.sshKnownHosts
     else:
         contents = getSshKnownHostsContents(self.sshHostKey)
     writeLocalFile(path, contents)
Ejemplo n.º 5
0
 def _downloadSshKnownHosts(self, path):
     if self.sshKnownHosts is not None:
         contents = self.sshKnownHosts
     else:
         contents = getSshKnownHostsContents(self.sshHostKey)
     writeLocalFile(path, contents)
Ejemplo n.º 6
0
 def _downloadSshPrivateKey(self, keyPath):
     # We change the permissions of the key file to be user-readable only so
     # that ssh does not complain. This is not used for security because the
     # parent directory will have proper permissions.
     writeLocalFile(keyPath, self.sshPrivateKey, mode=stat.S_IRUSR)
Ejemplo n.º 7
0
 def _downloadSshKnownHosts(self, path):
     writeLocalFile(path, getSshKnownHostsContents(self.sshHostKey))
Ejemplo n.º 8
0
 def createFileTemp(self, tempdir, filename, text="", chmodRights=0o700):
     file_path = os.path.join(tempdir, filename)
     writeLocalFile(file_path, text, chmodRights)
     return file_path
Ejemplo n.º 9
0
 def createFileTemp(self, tempdir, filename, text="", chmodRights=0o700):
     file_path = os.path.join(tempdir, filename)
     writeLocalFile(file_path, text, chmodRights)
     return file_path