Skip to content
Snippets Groups Projects
Commit c1ef9240 authored by Nicolas KAROLAK's avatar Nicolas KAROLAK
Browse files

try a scan port or a ping if cannot connect through ssh

parent 3d3cedb4
No related branches found
No related tags found
No related merge requests found
......@@ -40,6 +40,13 @@ def check_ssh(ip):
subprocess.check_output(cmd, shell=True, timeout=5)
print('%sLogged in successfully in "%s".%s' % (GREEN, ip, DEF))
except subprocess.CalledProcessError:
# do some diagnostics
try:
cmd_port = 'nc -z -w2 {} 22'.format(ip)
subprocess.check_output(cmd_port, shell=True, timeout=5)
except subprocess.CalledProcessError:
cmd_ping = 'ping -c2 -w4 {}'.format(ip)
subprocess.check_output(cmd_ping, shell=True, timeout=5)
print('%sFailed to login using SSH, run "ssh-copy-id %s".%s' % (RED, ip, DEF))
return False
return True
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment