It seems the socket connection through paramiko (v1.10.0) is not stable.
I have two computers. The python code is on the PC one. The connection sometime is successful and sometime is not (Same code). When the PC paramiko code fails (socket.error, 10060), I use my Mac via terminal ssh login the server and everything is fine.
I use set_missing_host_key_policy in the code. But the Mac has the key I guess. I typed yes when login at the first time.
If the unstable connection is caused by the hotkey, how do I get the host key? From the server or somewhere in my local folder (win7)?
Try switching off Windows firewall. It's a network error, it should not be because of SSH key problems.
Error Code 10060: Connection timeout
Background: The gateway could not receive a timely response from the website you are trying to access. This might indicate that the network is congested, or that the website is experiencing technical difficulties.
Related
The following code works flawlessly in Linux, retrieving the list of folders/files available in the FTP server:
from ftplib import FTP
server = FTP('ftp.ibge.gov.br')
server.connect()
server.login()
server.nlst()
However, in Windows 10, I get the server welcome message after connect() and the '230 login successful" message, but when I try to send any command to the server - like server.nlst() or server.dir() - socket.py raises a TimeoutError [WinError 10060]
I am 100% sure that the server is up, and in Linux server.nlst() retrieves the information fast as lightning - so, it is not a "true" timeout error, if I set timeout=1000, or larger, I get the same error.
What is wrong?
An explanation of the problem can be found here: passive reply with unroutable address
It seems that 'ftp.ibge.gov.br' is not properly configured.
Luckily, I found a working solution.
However, it seems that ftplib is not able to handle this problem in Windows only. With Linux, I have been accessing files from this server for years using ftplib
I am new to python socket programming and was following a tutorial building a chat-app, using kivy and sockets. I am running my server on my main PC and I was trying to connect from my laptop to this Server, but it doesn't work (Both my PC and laptop are connected via Ethernet cable). When I run the client.py on the PC that I host my Server on, everything works fine.
I tried running the Server on my 0.0.0.0 address and then connecting from my laptop to the IP address that appears on my Server PC if I type in "ipconfig" (192.168.2.x) but it didn't work. I also tried running the server just on the Ethernet-Adapter IP that appears when I type in "ipconfig" (so 192.168.2.x) but this doesn't work neither.
Lastly I have tried defining my Server IP by using the built in socket function: socket.gethostbyname(socket.gethostname()) (weirdly when I run this, my Server runs on my VMware Network Adapter (192.168.66.x) instead of my Ethernet-Adapter). But this too didn't work :(
The client.py code on my laptop always returns this error:
connection error: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Would appreciate any help :)
edit: Could this have something to do with the firewall on my PC blocking connections or something?
Found the Problem! Today it actually worked by disabling my host PCs Windows Defender internal Firewall and the running the Server on 0.0.0.0, which is very weird because yesterday it didn't work...
I've been trying to connect to first an out-of-band management server (in my case, since I'm connecting to DELL-servers, an iDRAC) and through that connect to the main server itself. I've got it to work when I do it manually, using, in the (windows) terminal:
putty.exe -ssh 'username'#'iDRAC-IP'
followed by PuTTY window opening where I type in the password, followed by
connect
which connects to the server itself, and then I type in the username and password for the server, completing the process.
When I've been writing my script in python, I'm using paramiko, http://www.paramiko.org/, suggested here on stackoverflow, and following this example: https://www.ivankrizsan.se/2016/04/24/execute-shell-commands-over-ssh-using-python-and-paramiko/, and it works just splendid for the iDRAC (the first server I connect to). It also works when I type in
stdin, stdout, stderr = ssh_client.exec_command('connect')
because I am still in my first server (ssh_client) (I can tell this is working because when I try to connect to the server manually afterwards, it is occupied). But after that it stops working, since when doing 'connect' I am no longer in ssh_client, but in a different server.
So my question is - how do I connect to a server from another server (in this case being the out-of-band management server) and log in to this one?
You can use ssh tunnel to do so.
this post may resolve your problem:
PyCharm: Configuring multi-hop remote Interpreters via SSH
I have 500 clients use the program, the program use python 2.7.12 + pyqt, the OS is windows XP, But now a computer has a error. The error is that when use urllib.urlopen, it returns socket error, error code is 10061.
But, i.e., the server IP is 192.168.1.12, the computer can open the web page use IE browser with http://192.168.1.12, and use the cmd: telnet 192.168.1.12 80, it's fine.
The computer's Windows firewall is disabled, and the antivirus software is closed. But when use urllib.urlopen('http://192.168.1.12'), it always returns socket error 10061. The other 500 clients don't have this issue, only this one. And I checked the IE browser settings, it's not set proxy. Anybody can help me ? I need your help, thanks all.
I'm having a problem with a Python script which should check if the user is connected to a wifi network with a captive portal. Specifically, the script is long-running, attempting to connect to example.org every 60 seconds.
The problem is that if the network starts offline (meaning the wifi isn't connected at the start of the script), socket.getaddrinfo will always fail with the error "Name or service not known", even once the wifi is connected, until the Python script is restarted. (This isn't a DNS thing -- all requests fail.)
Because both urllib and requests use sockets, it's totally impossible to download an example page once Python gets into this state.
Is there a way around this or a way to reset sockets so it works properly once the network fails?
To be clear, here's a repro:
Disconnect wifi
Run an interactive Python session
import urllib and urllib.open("http://stackoverflow.com/") -- fails as expected
Reconnect wifi
urllib.open("http://example.com/")
Expected: Returned HTML from example.com
Actual: socket.gaierror: [Errno -2] Name or service not known
If you're not connected to an access point when running the script, and don't have an IP address assigned to your device socket.getaddrinfo will fail. Maybe it's still connecting when you run the script. The domain name cannot be resolved because you are not connected to the network, thus no DNS.
Does it fail when you're actually connected to the network? Does curl http://icanhazip.com work at the point when the script fails? Or if you run ifconfig does your device have an IP? (I'm assuming you're on a *nix box).