def _write_private_key_file(self, filename, key, format, password=None):
with open(filename, "<STR_LIT:w>") as f:<EOL><INDENT>os.chmod(filename, o600)<EOL>self._write_private_key(f, key, format, password=password)<EOL><DEDENT>
Write an SSH2-format private key file in a form that can be read by
paramiko or openssh.  If no password is given, the key is written in
a trivially-encoded format (base64) which is completely insecure.  If
a password is given, DES-EDE3-CBC is used.

:param str tag:
    ``"RSA"`` or ``"DSA"``, the tag used to mark the data block.
:param filename: name of the file to write.
:param str data: data blob that makes up the private key.
:param str password: an optional password to use to encrypt the file.

:raises: ``IOError`` -- if there was an error writing the file.