I have some problems with Python and Paramiko. I want to connect to a SSH Server to automatically read some information from different systems.
I tried some Tips I found here but nothing works. I checked the hosts file, reinstall Python using brew, update/upgrade Python and Paramiko, used the ssh-server on my localhost to test. Also running pip to update paramiko and python.
I am very confused. Please let me ask you.
This is my working environment:
- MacOS Sierra 10.12.6
- Python 2.7
- Eclipse
- SSH Library: Paramiko (paramiko-2.2.1-py2.py3-none-any.whl)
The Script: Basic Paramiko SSH Connection
'''
Created on 16.09.2017
'''
import sys
import telnetlib
import paramiko
host = '213.000.000.123' #
user = "user"
password = "password"
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host, user, password)
Running the Script on Eclipse results with this output:
Traceback (most recent call last):
File "/Users/tschaefer/Documents/workspace/PythonCMTSLibs/basicSSHSessionModule.py", line 17, in <module>
ssh.connect(host, user, password)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/paramiko/client.py", line 301, in connect
to_try = list(self._families_and_addresses(hostname, port))
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/paramiko/client.py", line 199, in _families_and_addresses
hostname, port, socket.AF_UNSPEC, socket.SOCK_STREAM)
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
Ok, I find out gai=getaddrinfo, also getaddrbyname and so on. So I think there is a problem resolving the host-string to an IP Address. But it doesn't make sense resolving an IP Address to an IP Address. I used explicit IP. Using the "ssh 213.000.000.123" command directly on CLI works fine.
I also tried to connect to "localhost" or "127.0.0.1" or "google.com" or other. The hosts-file-entry is not commented so it's active. Result: the same situation.
NSLOOKUP works correct, so the DNS Lookup works and a DNS server is available.
It seems Python could find the paramiko Library starting in Eclipse, but there is a problem in the Library.
Can anyone help me the see what my eye doesn't see.
Thank a lot!
Greetings