I am trying to connect to some SFTP using a private key file that looks like:
---- BEGIN SSH2 ENCRYPTED PRIVATE KEY ----
Subject: L0709146
Comment: "1024-bit dsa, L0709146@pxz102, Wed Jan 12 2022 11:25:54 +010\
0"
P2/bla...bla...bla
---- END SSH2 ENCRYPTED PRIVATE KEY ----
Using the following code:
import paramiko
path = "path/to/my/file"
transport = paramiko.Transport((self.host, self.port))
transport.connect(username=self.user,pkey=paramiko.DSSKey.from_private_key(open(path)))
# ^^^ Error line ^^^
#transport.connect(username=self.user,pkey=paramiko.RSAKey.from_private_key(open(path)))
#transport.connect(username=self.user,pkey=paramiko.ECDSAKey.from_private_key(open(path)))
sftp = paramiko.SFTPClient.from_transport(transport)
logging.info(sftp.listdir())
I'm not sure but I understand that is a DSA private key file, but I obtained the error:
paramiko.ssh_exception.SSHException: not a valid DSA private key file
I tried with other options but, a similar error
paramiko.ssh_exception.SSHException: not a valid RSA private key file
paramiko.ssh_exception.SSHException: not a valid EC private key file
paramiko.ssh_exception.SSHException: not a valid OPENSSH private key file
I used the FileZilla client, I hadn't problem connecting to the SFTP, I don't get why with Python I have problems.