如何解决pysftp 身份验证超时
我正在尝试使用 pysftp 自动执行 sftp 传输。目前,我在使用 pysftp 说明书中的代码时遇到身份验证超时错误。这是回溯
我也可以使用 sftp -i
代码现在正在 VM 上运行,但可以确认相同的代码在我的本地运行。我正在使用 pyhton 3.7 和最新的 pysftp lib
有什么帮助吗?
import sys
import traceback
import pysftp
# get the arguments passed from cmd
hostname = sys.argv[1]
userid = sys.argv[2]
keyFile = sys.argv[3]
logfile = sys.argv[4]
try:
with pysftp.Connection(hostname,username=userid,private_key = keyFile,log=logfile) as sftp:
print ('Success')
except Exception:
traceback.print_exc()
这里是pysftp的日志
DEB [20210216-03:11:42.696] thr=1 paramiko.transport: starting thread (client mode): 0x58307708
DEB [20210216-03:11:42.697] thr=1 paramiko.transport: Local version/idstring: SSH-2.0-paramiko_2.7.2
DEB [20210216-03:11:43.672] thr=1 paramiko.transport: Remote version/idstring: SSH-2.0-OpenSSH_6.4
INF [20210216-03:11:43.673] thr=1 paramiko.transport: Connected (version 2.0,client OpenSSH_6.4)
DEB [20210216-03:11:43.736] thr=1 paramiko.transport: kex algos:['ecdh-sha2-nistp256','ecdh-sha2-nistp384','ecdh-sha2-nistp521','diffie-hellman-group-exchange-sha256','diffie-hellman-group-exchange-sha1','diffie-hellman-group14-sha1','diffie-hellman-group1-sha1'] server key:['ssh-rsa'] client encrypt:['aes128-ctr','aes192-ctr','aes256-ctr'] server encrypt:['aes128-ctr','aes256-ctr'] client mac:['hmac-md5-etm@openssh.com','hmac-sha1-etm@openssh.com','umac-64-etm@openssh.com','umac-128-etm@openssh.com','hmac-sha2-256-etm@openssh.com','hmac-sha2-512-etm@openssh.com','hmac-ripemd160-etm@openssh.com','hmac-sha1-96-etm@openssh.com','hmac-md5-96-etm@openssh.com','hmac-md5','hmac-sha1','umac-64@openssh.com','umac-128@openssh.com','hmac-sha2-256','hmac-sha2-512','hmac-ripemd160','hmac-ripemd160@openssh.com','hmac-sha1-96','hmac-md5-96'] server mac:['hmac-md5-etm@openssh.com','hmac-md5-96'] client compress:['none'] server compress:['none'] client lang:[''] server lang:[''] kex follows?False
DEB [20210216-03:11:43.737] thr=1 paramiko.transport: Kex agreed: ecdh-sha2-nistp256
DEB [20210216-03:11:43.737] thr=1 paramiko.transport: HostKey agreed: ssh-rsa
DEB [20210216-03:11:43.738] thr=1 paramiko.transport: Cipher agreed: aes128-ctr
DEB [20210216-03:11:43.738] thr=1 paramiko.transport: MAC agreed: hmac-sha2-256
DEB [20210216-03:11:43.738] thr=1 paramiko.transport: Compression agreed: none
DEB [20210216-03:11:44.192] thr=1 paramiko.transport: kex engine KexNistp256 specified hash_algo <built-in function openssl_sha256>
DEB [20210216-03:11:44.193] thr=1 paramiko.transport: Switch to new keys ...
DEB [20210216-03:11:44.194] thr=2 paramiko.transport: Host key verified (ssh-rsa)
DEB [20210216-03:11:44.194] thr=2 paramiko.transport: Attempting public-key auth...
DEB [20210216-03:11:44.430] thr=1 paramiko.transport: userauth is OK
DEB [20210216-03:12:14.378] thr=1 paramiko.transport: EOF in transport thread.
我现在在移动设备上没有回溯的文本格式。收到后会再更新
解决方法
看起来是服务器的问题。不知何故,代码在身份验证期间超时。使用 paramiko 的 auth_timeout 参数有效。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。