1

I have a server in which many machines are managed. I am able to connect and run commands on server using paramiko, but i am not able to login to machines on that server. Script :-

#!/usr/bin/python
#to view time of EMS
import paramiko
ssh = paramiko.SSHClient()
enter code heressh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('x.x.x.x', username = 'AAA', password = 'BBB')
stdin, stdout, stderr = ssh.exec_command('date')
print(stdout.read())
client = paramiko.SSHClient()
ssh.connect('y.y.y.y', username= 'CCC', password='DDD')


socket.error: [Errno 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
  • Can you login via ssh normally (on the command line) from that server to your machines? – 9769953 Jul 29 '19 at 09:38
  • It's unclear if you indeed want to log in to *other* machines after having logged in to a (separate) server, and if you want to do all of that using Paramiko? That is, do you want to use it in a chain of local machine-A -> paramiko -> server-B -> paramiko -> machine-C? – 9769953 Jul 29 '19 at 09:41
  • yes manual ssh is working fine. I ssh into server and from there i can ssh the machine 1 – Mukesh Narwal Jul 29 '19 at 11:45
  • But are you running this Python code on that server? – 9769953 Jul 29 '19 at 14:49

2 Answers2

0

socket.error: [Errno 10060] is basically a Connection timed out error.

It might be some proxy or networking issue. It's the OS telling you the socket connection timed out or nobody was listening at the other end. Paramiko isn't what's raising the error itself.

I'd make sure the connection to that and port via the OpenSSH client, or netcat nc -z <IP> 22

Deepansh
  • 73
  • 7
0

check ssh service is running in the remote machine or not. service ssh stastus. It should show active and running. other wise run below command. service ssh start.

As Deepansh mentioned it may be proxy error also. in that is the case need to add your remote ip in to no_proxy environment variable

samba
  • 869
  • 4
  • 12
  • 20