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
Note that I don't want to use the SSH agent, just the Paramiko module alone.
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://myroughnotes.wordpress.com/2017/03/19/fabric-could-not-get-keys-from-ssh-agent/
https://unix.stackexchange.com/questions/82489/how-to-check-which-ssh-keys-are-currently-active
# eval ssh-agent -s
SSH_AUTH_SOCK=/tmp/ssh-PycvG5kzoTjt/agent.26174; export SSH_AUTH_SOCK;
SSH_AGENT_PID=26175; export SSH_AGENT_PID;
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)