This commit is contained in:
rasmus 2020-12-22 01:34:18 +02:00
parent 3c05587f1a
commit 3e5b77ee8d
1 changed files with 13 additions and 6 deletions

19
main.py
View File

@ -1,7 +1,8 @@
# External deps # External deps
import paramiko import paramiko # for ssh
import logging import logging # for possible debugging
from time import sleep from time import sleep # for sleep()
import os # for CLI arguments
# Local deps # Local deps
import listServers, relativeUsage import listServers, relativeUsage
@ -10,10 +11,16 @@ import listServers, relativeUsage
#logging.basicConfig() #logging.basicConfig()
#logging.getLogger("paramiko").setLevel(logging.DEBUG) #logging.getLogger("paramiko").setLevel(logging.DEBUG)
"""
ENV VARIABLES AVAILABLE:
- hostname
- sshkeylocation (optional)
- sshuser (optional)
"""
# Creds # Creds
hostname = '172.23.224.40' hostname = str(os.environ['hostname'])
sshuser = 'Administrator' sshuser = str(os.getenv('sshuser', 'Administrator'))
sshkeylocation = '/home/jc/.ssh/id_rsa' sshkeylocation = str(os.path.abspath( os.getenv('sshkeypath', '~/.ssh/id_rsa') ))
paramiko.transport.Transport._preferred_keys += ('ssh-dss',) # Allow the insecurities paramiko.transport.Transport._preferred_keys += ('ssh-dss',) # Allow the insecurities
ssh = paramiko.SSHClient() # Alias ssh = paramiko.SSHClient() # Alias