Skip to content

Commit

Permalink
better authentication failure handling
Browse files Browse the repository at this point in the history
  • Loading branch information
caplan committed Oct 6, 2016
1 parent 92540a8 commit 1f5cd1b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions soloutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ def _connect(ip, await=True, silent=False):
socket.setdefaulttimeout(5)
message = silent
start = time.time()
tryCount = 0
while True:

if (tryCount >= 5):
print 'error: unable to connect after {} attempts, giving up.'.format(tryCount)
sys.exit(1)

tryCount = tryCount + 1

try:
client.connect(ip, username='root', password='TjSDBkAu', timeout=5)
except paramiko.BadHostKeyException:
Expand All @@ -39,6 +47,9 @@ def _connect(ip, await=True, silent=False):
print ''
print 'and try again'
sys.exit(1)
except paramiko.AuthenticationException as e:
print 'ssh authentication error'
raise e
except Exception as e:
if not await:
raise e
Expand Down

0 comments on commit 1f5cd1b

Please sign in to comment.