PYSTFP身份验证超时

2024-05-20 01:32:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用pysftp自动化sftp传输。目前,我在使用PySTFP cookbook中的代码时遇到身份验证超时错误。这是回溯

Traceback

我也可以使用sftp -i <id_file> userid@hostname登录到服务器,因此端口和凭据应该是正确的

该代码现在正在VM上运行,但可以确认相同的代码在本地运行。我正在使用Python3.7和最新的PySTFP库

有什么帮助吗

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()

这是PYSTFP的日志

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', 'aes192-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-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'] 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.

Tags: comclientparamikodebhmacsha1md5transport