I'am trying to establish a test connection to an sftp server. (as demonstrated in Python Pysftp Error). I got the key from the server by establishing a first connection to the server via terminal. That worked flawlessly. However if I run the python script:
import pysftp
sftp = pysftp.Connection('test.rebex.net', username='demo', password='password')
data = s.listdir()
sftp.close()
for i in data:
print(i)
I get the following error message:
> Traceback (most recent call last): File "/home/pi/Documents/Python
> Projects/ftp_connection.py", line 24, in <module>
> sftp = pysftp.Connection('test.rebex.net', username='demo', password='password') File
> "/usr/local/lib/python3.4/dist-packages/pysftp-0.2.9-py3.4.egg/pysftp/__init__.py",
> line 116, in __init__
> self._cnopts = cnopts or CnOpts() File "/usr/local/lib/python3.4/dist-packages/pysftp-0.2.9-py3.4.egg/pysftp/__init__.py",
> line 54, in __init__
> self.hostkeys.load(knownhosts) File "/usr/local/lib/python3.4/dist-packages/paramiko-2.1.2-py3.4.egg/paramiko/hostkeys.py",
> line 101, in load
> e = HostKeyEntry.from_line(line, lineno) File "/usr/local/lib/python3.4/dist-packages/paramiko-2.1.2-py3.4.egg/paramiko/hostkeys.py",
> line 335, in from_line
> key = ECDSAKey(data=decodebytes(key), validate_point=False) File "/usr/local/lib/python3.4/dist-packages/paramiko-2.1.2-py3.4.egg/paramiko/ecdsakey.py",
> line 138, in __init__
> self.verifying_key = numbers.public_key(backend=default_backend()) File
> "/usr/local/lib/python3.4/dist-packages/cryptography-1.8.1-py3.4-linux-armv7l.egg/cryptography/hazmat/backends/__init__.py",
> line 74, in default_backend
> _default_backend = MultiBackend(_available_backends()) File "/usr/local/lib/python3.4/dist-packages/cryptography-1.8.1-py3.4-linux-armv7l.egg/cryptography/hazmat/backends/__init__.py",
> line 31, in _available_backends
> "cryptography.backends" File "/usr/local/lib/python3.4/dist-packages/cryptography-1.8.1-py3.4-linux-armv7l.egg/cryptography/hazmat/backends/__init__.py",
> line 30, in <listcomp>
> for ep in pkg_resources.iter_entry_points( File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2190, in load
> ['__name__']) File "/usr/local/lib/python3.4/dist-packages/cryptography-1.8.1-py3.4-linux-armv7l.egg/cryptography/hazmat/backends/openssl/__init__.py",
> line 7, in <module>
> from cryptography.hazmat.backends.openssl.backend import backend File
> "/usr/local/lib/python3.4/dist-packages/cryptography-1.8.1-py3.4-linux-armv7l.egg/cryptography/hazmat/backends/openssl/backend.py", line 49, in <module>
> from cryptography.hazmat.bindings.openssl import binding File "/usr/local/lib/python3.4/dist-packages/cryptography-1.8.1-py3.4-linux-armv7l.egg/cryptography/hazmat/bindings/openssl/binding.py", line 12, in <module>
> from cryptography.hazmat.bindings._openssl import ffi, lib ImportError: libssl.so.1.1: cannot open shared object file: No such
> file or directory
I checked the /etc/ld.so.conf.d/libc.conf file to have a look at the search path which is /usr/local/lib. In said path I can find the libssl.so.1.1 file. Does anyone have a suggestion on how to interpret the error message or knows where I went wrong? Thanks a lot.
Nevermind me bothering you. The solution was easy: Turns out I had to run:
sudo ldconfig
As has been previously suggested in Linux error while loading shared libraries: cannot open shared object file: No such file or directory