473,466 Members | 1,451 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do I fix "socket.gaierror: [Errno -2] Name or service not known" when using paramiko?

1 New Member
I am trying to send an email in my python script via ssh. However, I keep getting
Expand|Select|Wrap|Line Numbers
  1. socket.gaierror: [Errno -2] Name or service not known
.
I searched google for it and found this: https://stackoverflow.com/questions/...vice-not-known, but that doesn't solve the problem, as I can connect like normal to the server using a terminal, only in Python it's not working.
I also found this source: https://www.programcreek.com/python/...ocket.gaierror, but a simple try-except won't help, if the code *always* runs into this error, not just occasionally.

The code I use:
Expand|Select|Wrap|Line Numbers
  1. import paramiko
  2. hostname, sshport, username, password = splitLine
  3.             print(splitLine)
  4.             ssh = paramiko.SSHClient()
  5.             ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  6.             ssh.connect(hostname, port=int(sshport), username=username, password=password)
  7.  
splitLine is a line I read from a txt-File beforehand, looking like this (with actual data of course):
Expand|Select|Wrap|Line Numbers
  1. my_server_adress port username password
  2.  
It is preformatted and then split into a python list: ["my_server_adress", "port", "username", "password"].
I also tried the port with and without conversion to an integer, get the same error both times.
Aug 9 '21 #1
0 4345

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: hanjar | last post by:
Hello, I'm using paramiko 0.9 to access one of my home machines and then execute a command. But with the script included below, the command gets executed on the 2nd to 6th go, never on the...
5
by: Subrahmanyam Arya | last post by:
Dear oracle gurus, I am unable to get past the error ORA-12154: TNS: could not resolve service name on my host when using hsodbc to talk to a remote mysql database. i got from the meta link all...
2
by: Shads | last post by:
Hi, I receive this error in the System Event Log? Event Type: Error Event Source: Service Control Manager Event Category: None Event ID: 7031 Date: 15/08/2005 Time: 22:22:32
0
by: d.gallone | last post by:
Hello, I'm using VB .NET 2003 and I want to add a web reference at run time. I've a app.config file where the web references are defined, but how to call the service method defined in the wsdl ?...
2
by: flamesrock | last post by:
Hi, Basically, I'm trying to send a multipart form to a server using some code from aspn.. here it is: MultipartPostHandler: http://pastie.caboo.se/29833 import MultipartPostHandler, urllib2,...
1
by: sa6113 | last post by:
I use this code : import paramiko import socket hostname = "192.168.1.4" username = "test" port = 22 password = ''123456"
4
by: sa6113 | last post by:
I couldn't find any good source for download Openssh on the net? Would you please introduce a URL for download that? Steve Holden-5 wrote: -- View this message in context:...
0
by: sa6113 | last post by:
I am using this code to connect to a windows machine using paramiko, I have installed sshd on the machine and it works properly: sock.connect((hostname, port)) t = paramiko.Transport(sock)...
0
by: sa6113 | last post by:
which program I have to install for using paramiko for sftp between a two windows machine in local network?? I have installed freeSSHd for server machine but I got an Authentication failed erro...
0
by: sa6113 | last post by:
I want to connect to a Windows machine in my network , using ssh, I use paramiko but I have problem in authentication, would you please help me? 1- I have installed freeSSHD in server machine? Is...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.