使用 pysftp 设置到服务器的测试连接
Setting up test connection to server using pysftp
我正在尝试建立到 sftp 服务器的测试连接。 (如 Python Pysftp Error 所示)。我通过终端建立与服务器的第一个连接,从服务器获取了密钥。那工作完美无缺。但是,如果我 运行 python 脚本:
import pysftp
sftp = pysftp.Connection('test.rebex.net', username='demo', password='password')
data = s.listdir()
sftp.close()
for i in data:
print(i)
我收到以下错误消息:
> 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
我检查了 /etc/ld.so.conf.d/libc.conf 文件以查看搜索路径 /usr/local/lib。在上述路径中,我可以找到 libssl.so.1.1 文件。有没有人对如何解释错误消息有建议或知道我哪里出错了?非常感谢。
别打扰我了。解决方案很简单:
结果我不得不 运行:
sudo ldconfig
正如之前在 Linux error while loading shared libraries: cannot open shared object file: No such file or directory
中所建议的那样
我正在尝试建立到 sftp 服务器的测试连接。 (如 Python Pysftp Error 所示)。我通过终端建立与服务器的第一个连接,从服务器获取了密钥。那工作完美无缺。但是,如果我 运行 python 脚本:
import pysftp
sftp = pysftp.Connection('test.rebex.net', username='demo', password='password')
data = s.listdir()
sftp.close()
for i in data:
print(i)
我收到以下错误消息:
> 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
我检查了 /etc/ld.so.conf.d/libc.conf 文件以查看搜索路径 /usr/local/lib。在上述路径中,我可以找到 libssl.so.1.1 文件。有没有人对如何解释错误消息有建议或知道我哪里出错了?非常感谢。
别打扰我了。解决方案很简单: 结果我不得不 运行:
sudo ldconfig
正如之前在 Linux error while loading shared libraries: cannot open shared object file: No such file or directory
中所建议的那样