I'm trying into login into a remote server using paramiko. But it is getting failed with below error
File "/root/xat-pvt-xat/ssh.py", line 30, in check_aux_host_for_file
dsakey = paramiko.DSSKey.from_private_key(file_obj=credentials[env]["sftp_pass"])
File "/root/python3-virtualenv/lib64/python3.6/site-packages/paramiko/pkey.py", line 217, in from_private_key
key = cls(file_obj=file_obj, password=password)
File "/root/python3-virtualenv/lib64/python3.6/site-packages/paramiko/dsskey.py", line 52, in __init__
self._from_private_key(file_obj, password)
File "/root/python3-virtualenv/lib64/python3.6/site-packages/paramiko/dsskey.py", line 232, in _from_private_key
data = self._read_private_key('DSA', file_obj, password)
File "/root/python3-virtualenv/lib64/python3.6/site-packages/paramiko/pkey.py", line 272, in _read_private_key
lines = f.readlines()
AttributeError: 'str' object has no attribute 'readlines'
#Implementation
pr_pkey ="""
THE PRIVATE KEY
"""
dsakey = paramiko.DSSKey.from_private_key(pr_pkey)
I tried placing this in a pem file and I tried with below command. dsakey = paramiko.DSSKey.from_private_key_file(open('pr_ssh_key.pem','r'))
Unfortunately that also got failed with below error
dsakey = paramiko.DSSKey.from_private_key_file(open('pr_ssh_key.pem','r'))
File "/root/python3-virtualenv/lib64/python3.6/site-packages/paramiko/pkey.py", line 196, in from_private_key_file
key = cls(filename=filename, password=password)
File "/root/python3-virtualenv/lib64/python3.6/site-packages/paramiko/dsskey.py", line 55, in __init__
self._from_private_key_file(filename, password)
File "/root/python3-virtualenv/lib64/python3.6/site-packages/paramiko/dsskey.py", line 228, in _from_private_key_file
data = self._read_private_key_file('DSA', filename, password)
File "/root/python3-virtualenv/lib64/python3.6/site-packages/paramiko/pkey.py", line 267, in _read_private_key_file
with open(filename, 'r') as f:
TypeError: expected str, bytes or os.PathLike object, not _io.TextIOWrapper
It would be great if someone could help me to identify what is missing in my implementation. Thanks in advance