azure OSError“Incorrect function:'\\\.\\pipe\\'“通过Paramiko建立SSH连接时[重复]

iyfjxgzm  于 2023-03-24  发布在  其他
关注(0)|答案(1)|浏览(152)

此问题在此处已有答案

How to solve "paramiko.ssh_exception.SSHException: could not get keys from ssh-agent"(1个答案)
3天前关闭。
我正在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 = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname=ftp_host, port=ftp_port, username=ftp_user, password=ftp_pwd)

有谁知道我该怎么解决这个问题吗?
先谢了

axr492tv

axr492tv1#

通过将allow_agent=False传递给SSHClient.connect()解决了该问题

相关问题