如何在pysftp中为凭证定义字符集?

问题描述 投票:1回答:2

我正在尝试从远程服务器下载文件。为此,我需要定义“ charset = ASCII”(我在FileZilla客户端中尝试过)。然后只有连接成功,我才能查看文件。否则我从客户端(使用FileZilla客户端)得到'Authentication error'

我正在使用pysftp库在我的Python程序中连接同一远程服务器;

 connOption = pysftp.CnOpts()
 connOption.hostkeys = None
    srv = pysftp.Connection(host=host, username=username, password=password, port=port, cnopts=connOption)

我不知道如何在这里定义Charset参数。没有用于连接方法的字符集参数。

我应该如何使用pysftp?

paramiko.ssh_exception.AuthenticationException:验证失败。

我的用户名包含_个字符。我只是从一个来源复制它,

例如:xxxxx_O’xxxxx

从FileZilla成功尝试:

Status: Connecting to xxxxx...
Status: Connected to xxxx
Status: Retrieving directory listing...
Status: Listing directory /
Status: Directory listing of "/" successful

日志文件输出:

2019-10-15 16:57:04 4480 1 Status: Connecting to xxxx...
2019-10-15 16:57:04 4480 1 Response: fzSftp started, protocol_version=8
2019-10-15 16:57:04 4480 1 Command: open "xxxx_O’xxxx@xxxxx" 22
2019-10-15 16:57:06 4480 1 Command: Trust new Hostkey: Once
2019-10-15 16:57:06 4480 1 Command: Pass: *********************
2019-10-15 16:57:06 4480 1 Status: Connected to xxxxxxx
2019-10-15 16:57:06 4480 1 Status: Retrieving directory listing...
2019-10-15 16:57:06 4480 1 Command: pwd
2019-10-15 16:57:06 4480 1 Response: Current directory is: "/"
2019-10-15 16:57:06 4480 1 Command: ls
2019-10-15 16:57:06 4480 1 Status: Listing directory /
2019-10-15 16:57:07 4480 1 Status: Directory listing of "/" successful

我正在尝试从远程服务器下载文件。为此,我需要定义“ charset = ASCII”(我在FileZilla客户端中尝试过)。然后只有连接成功,我才能查看文件。否则我得到'...

python ssh character-encoding pysftp
2个回答
1
投票

尝试使用字节文字指定密码:


0
投票

我对pysftp遇到同样的问题。请尝试这个。

© www.soinside.com 2019 - 2024. All rights reserved.