code: def copy_ssh_keys_to_host(self, host, password=None, no_add_host=False, known_hosts=DEFAULT_KNOWN_HOSTS):
          
          client = None
          try:
              client = paramiko.SSHClient()
              if not no_add_host:
                  client.set_missing_host_key_policy(paramiko.client.AutoAddPolicy())
              if os.path.isfile(known_hosts):
                  client.load_host_keys(filename=known_hosts)
  
              client.connect(host.hostname, port=host.port, username=host.user, password=password,
                             key_filename=self.priv_key)
  
              cmd = (r'''mkdir -p ~/.ssh && chmod 700 ~/.ssh && \
  k='{0}' && if ! grep -qFx "$k" ~/.ssh/authorized_keys; then echo "$k" >> ~/.ssh/authorized_keys; fi'''
                     .format(self.pub_key_content))
              logger.debug('Run on [%s]: %s', host.hostname, cmd)
              client.exec_command(cmd.encode('utf-8'))
          finally:
              if client:
                  client.close()
docs: Copy the SSH keys to the given host.
  
          :param host: the `Host` object to copy the SSH keys to.
          :param password: the SSH password for the given host.
          :param no_add_host: if the host is not in the known_hosts file, write an error instead of adding it to the
                              known_hosts.
          :param known_hosts: the `known_hosts` file to store the SSH public keys.
          :raise paramiko.ssh_exception.AuthenticationException: if SSH authentication error.
          :raise paramiko.ssh_exception.SSHException: generic SSH error.
          :raise socket.error: if error at the socket level.