Browse Source

Added ability to choose public key =]

Wazakindjes 4 years ago
parent
commit
f98edc78b5
1 changed files with 5 additions and 4 deletions
  1. 5 4
      hurr.py

+ 5 - 4
hurr.py

@@ -20,6 +20,7 @@ MUHCONF = {
 	'growlname': None,
 	'icondir': None,
 	'sshdir': None,
+	'sshkey': 'id_rsa',
 	'remotebase': None,
 	'urlbase': None,
 	'scrotdir': None,
@@ -88,7 +89,7 @@ def growlnotif(ID, errorid=None, errormsg=None):
 def upload(local, remote):
 	global AMOUNT, MUHCONF
 	try:
-		SSH.connect(MUHCONF['server'], username=MUHCONF['joeser']);
+		SSH.connect(MUHCONF['server'], username=MUHCONF['joeser'], key_filename="%s/%s" % (MUHCONF['sshdir'], MUHCONF['sshkey']));
 		sftp = SSH.open_sftp()
 		sftp.put(local, '%s/%s' % (MUHCONF['remotebase'], remote))
 		sftp.close()
@@ -107,7 +108,7 @@ def archiver():
 	global SSH, AMOUNT, MUHCONF
 	while True:
 		if AMOUNT >= MUHCONF['archivecount']:
-			SSH.connect(MUHCONF['server'], username=MUHCONF['joeser']);
+			SSH.connect(MUHCONF['server'], username=MUHCONF['joeser'], key_filename="%s/%s" % (MUHCONF['sshdir'], MUHCONF['sshkey']));
 			date = datetime.datetime.now()
 			folder = "%d-%02d-%02d--%02d:%02d:%02d" % (date.year, date.month, date.day, date.hour, date.minute, date.second)
 
@@ -217,7 +218,7 @@ if __name__ == "__main__":
 	OLDFILES_ALT = getscrots_alt()
 	OLDFILES_DB = getscrots_db()
 
-	print "Setting up SSH"
+	print "Setting up SSH using key pair: %s/%s" % (MUHCONF['sshdir'], MUHCONF['sshkey'])
 	SSH = paramiko.SSHClient()
 	SSH.known_hosts = None
 
@@ -250,7 +251,7 @@ if __name__ == "__main__":
 		args = []
 
 		print "Getting current image count"
-		SSH.connect(MUHCONF['server'], username=MUHCONF['joeser']);
+		SSH.connect(MUHCONF['server'], username=MUHCONF['joeser'], key_filename="%s/%s" % (MUHCONF['sshdir'], MUHCONF['sshkey']));
 		checkamount = 'ls -1 %s | wc -l' % MUHCONF['remotebase']
 		stdin, stdout, stderr = SSH.exec_command(checkamount)
 		AMOUNT = int(stdout.read().strip())