OSError when stablishing SSH connection through Paramiko

问题描述 投票:0回答:0

我在 Azure 自动化帐户中运行一个 Python 脚本,该脚本应该使用

paramiko
包通过 SFTP 连接发送一些数据。

脚本在我的电脑上执行时运行良好。但是在云环境中执行时,尝试使用

ssh.connect()
函数调用建立SSH连接时出现以下错误。

Traceback (most recent call last):
  File "C:\Temp\vjtgkdb0.eh1\xxxxxxx", line 587, in <module>
    generate_files()
  File "C:\Temp\xxxxx", line 50, in generate_files
    ssh.connect(hostname=ftp_host, port=ftp_port, username=ftp_user, password=ftp_pwd)
  File "C:\WPy64-3800\python-3.8.0.amd64\lib\site-packages\paramiko\client.py", line 459, in connect
    self._auth(
  File "C:\WPy64-3800\python-3.8.0.amd64\lib\site-packages\paramiko\client.py", line 717, in _auth
    self._agent = Agent()
  File "C:\WPy64-3800\python-3.8.0.amd64\lib\site-packages\paramiko\agent.py", line 403, in __init__
    conn = get_agent_connection()
  File "C:\WPy64-3800\python-3.8.0.amd64\lib\site-packages\paramiko\agent.py", line 230, in get_agent_connection
    elif win_openssh.can_talk_to_agent():
  File "C:\WPy64-3800\python-3.8.0.amd64\lib\site-packages\paramiko\win_openssh.py", line 32, in can_talk_to_agent
    return any(name == n.lower() for n in os.listdir(dir_)
OSError: [WinError 1] Incorrect function: '\\\\.\\pipe\\'

这是我用来建立连接的代码。在

ssh.connect()
函数调用中引发错误。

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname=ftp_host, port=ftp_port, username=ftp_user, password=ftp_pwd)

有人知道我该如何解决吗?

提前致谢

python azure ssh paramiko
© www.soinside.com 2019 - 2024. All rights reserved.