Skip to content

Commit

Permalink
Update connection.py
Browse files Browse the repository at this point in the history
  • Loading branch information
alvherrey committed May 10, 2022
1 parent 9e26d4c commit b88cebb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion utils/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,21 @@ def add_ssh_key(ip):


# Connect with ssh key
# Sometimes fails because paramiko bug:
# https://stackoverflow.com/questions/70565357/paramiko-authentication-fails-with-agreed-upon-rsa-sha2-512-pubkey-algorithm
# https://github.com/paramiko/paramiko/issues/1961
def ssh_key(ip):
try:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname=ip, port=22, username = "ahernandez", key_filename='id_rsa', timeout=5)

# To solve de bug
# ssh.connect(hostname=ip, port=22, username = "ahernandez", key_filename='id_rsa', timeout=5, disabled_algorithms=dict(pubkeys=["rsa-sha2-512", "rsa-sha2-256"]))

# stdin,stdout,stderr = ssh.exec_command("date")
# print(stderr.read())
print('%s\tOK'%(ip))
ssh.close()
except :
print('%s\tKO'%(ip))
print('%s\tKO'%(ip))

0 comments on commit b88cebb

Please sign in to comment.