如何解决"paramiko.ssh_exception.SSHException:无法从ssh-agent获取密钥" [英] How to solve "paramiko.ssh_exception.SSHException: could not get keys from ssh-agent"

查看:409
本文介绍了如何解决"paramiko.ssh_exception.SSHException:无法从ssh-agent获取密钥"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Paramiko Python模块通过SSH连接到远程服务器.使用Python版本3.6.7在CentOS 7服务器上安装.但是出现以下错误.

I'm trying to connect to remote server through SSH using Paramiko Python module. Installed using Python version 3.6.7 on CentOS 7 server. But getting this following error.

python
import paramiko
>>> ssh = paramiko.SSHClient()
>>> ssh.load_system_host_keys()
>>> ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
>>> ssh.connect("19.16.2.2", username="user1", password="pass")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/paramiko/client.py", line 424, in connect
    passphrase,
  File "/usr/local/lib/python3.6/site-packages/paramiko/client.py", line 643, in _auth
    self._agent = Agent()
  File "/usr/local/lib/python3.6/site-packages/paramiko/agent.py", line 372, in __init__
    self._connect(conn)
  File "/usr/local/lib/python3.6/site-packages/paramiko/agent.py", line 68, in _connect
    raise SSHException('could not get keys from ssh-agent')
paramiko.ssh_exception.SSHException: could not get keys from ssh-agent

请注意,我不想仅使用Paramiko模块就使用SSH代理.

Note that I don't want to use the SSH agent, just the Paramiko module alone.

我用Google搜索并尝试了以下解决方案.我仍然无法解决此问题.如果提供了解决方案,将不胜感激.提前致谢.

I googled and tried the following solutions. Still I was not able to resolve this issue. Would appreciate if provided a solution. Thanks in advance.

https://access.redhat.com/solutions/3571001

https://unix.stackexchange.com/questions/82489/如何检查当前ssh键是否处于活动状态

# eval ssh-agent -s
SSH_AUTH_SOCK=/tmp/ssh-PycvG5kzoTjt/agent.26174; export SSH_AUTH_SOCK;
SSH_AGENT_PID=26175; export SSH_AGENT_PID;

推荐答案

如果您不想使用身份验证代理,则可以避免Paramiko尝试使用 SSHClient.connect :

If you do not want to use authentication agent, you can avoid Paramiko trying to contact it using allow_agent argument of SSHClient.connect:

ssh.connect("19.16.2.2", username="user1", password="pass", allow_agent=False)

这篇关于如何解决"paramiko.ssh_exception.SSHException:无法从ssh-agent获取密钥"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆