mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-08 06:16:08 +01:00
minor fix to backup destinations
This commit is contained in:
@@ -639,15 +639,26 @@ class backupUtilities:
|
|||||||
def sendKey(IPAddress, password,port):
|
def sendKey(IPAddress, password,port):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
expectation = []
|
||||||
|
expectation.append("password:")
|
||||||
|
expectation.append("Password:")
|
||||||
|
expectation.append("Permission denied")
|
||||||
|
|
||||||
command = "sudo scp -o StrictHostKeyChecking=no -P "+ port +" /root/.ssh/cyberpanel.pub root@" + IPAddress + ":/root/.ssh/authorized_keys"
|
command = "sudo scp -o StrictHostKeyChecking=no -P "+ port +" /root/.ssh/cyberpanel.pub root@" + IPAddress + ":/root/.ssh/authorized_keys"
|
||||||
|
setupKeys = pexpect.spawn(command, timeout=3)
|
||||||
|
|
||||||
sendKeyProc = pexpect.spawn(command,timeout=3)
|
index = setupKeys.expect(expectation)
|
||||||
sendKeyProc.expect("password:")
|
|
||||||
|
|
||||||
sendKeyProc.sendline(password)
|
## on first login attempt send password
|
||||||
sendKeyProc.expect("100%")
|
|
||||||
|
|
||||||
sendKeyProc.wait()
|
if index == 0:
|
||||||
|
setupKeys.sendline(password)
|
||||||
|
elif index == 1:
|
||||||
|
setupKeys.sendline(password)
|
||||||
|
elif index == 2:
|
||||||
|
return [0, 'Please enable password authentication on your remote server.']
|
||||||
|
else:
|
||||||
|
raise BaseException
|
||||||
|
|
||||||
return [1, "None"]
|
return [1, "None"]
|
||||||
|
|
||||||
@@ -671,15 +682,18 @@ class backupUtilities:
|
|||||||
if backupUtilities.checkIfHostIsUp(IPAddress) == 1:
|
if backupUtilities.checkIfHostIsUp(IPAddress) == 1:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
return [0,"Host is Down."]
|
logging.CyberCPLogFileWriter.writeToFile("Host is Down.")
|
||||||
|
#return [0,"Host is Down."]
|
||||||
|
|
||||||
expectation = []
|
expectation = []
|
||||||
expectation.append("password:")
|
expectation.append("password:")
|
||||||
|
expectation.append("Password:")
|
||||||
expectation.append("Permission denied")
|
expectation.append("Permission denied")
|
||||||
|
|
||||||
command = "sudo ssh -o StrictHostKeyChecking=no -p "+ port +" root@"+IPAddress+" mkdir /root/.ssh"
|
command = "sudo ssh -o StrictHostKeyChecking=no -p "+ port +" root@"+IPAddress+" mkdir /root/.ssh"
|
||||||
|
logging.CyberCPLogFileWriter.writeToFile(command)
|
||||||
|
|
||||||
setupKeys = pexpect.spawn(command,timeout=3)
|
setupKeys = pexpect.spawn(command, timeout=3)
|
||||||
|
|
||||||
index = setupKeys.expect(expectation)
|
index = setupKeys.expect(expectation)
|
||||||
|
|
||||||
@@ -688,6 +702,8 @@ class backupUtilities:
|
|||||||
if index == 0:
|
if index == 0:
|
||||||
setupKeys.sendline(password)
|
setupKeys.sendline(password)
|
||||||
elif index == 1:
|
elif index == 1:
|
||||||
|
setupKeys.sendline(password)
|
||||||
|
elif index == 2:
|
||||||
return [0, 'Please enable password authentication on your remote server.']
|
return [0, 'Please enable password authentication on your remote server.']
|
||||||
else:
|
else:
|
||||||
raise BaseException
|
raise BaseException
|
||||||
@@ -705,7 +721,7 @@ class backupUtilities:
|
|||||||
elif index == 1:
|
elif index == 1:
|
||||||
setupKeys.wait()
|
setupKeys.wait()
|
||||||
|
|
||||||
sendKey = backupUtilities.sendKey(IPAddress,password,port)
|
sendKey = backupUtilities.sendKey(IPAddress, password, port)
|
||||||
|
|
||||||
if sendKey[0] == 1:
|
if sendKey[0] == 1:
|
||||||
return [1, "None"]
|
return [1, "None"]
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ class remoteBackup:
|
|||||||
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [getKey]")
|
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [getKey]")
|
||||||
return [0,"Not able to fetch key from remote server, Error Message:" + str(msg)]
|
return [0,"Not able to fetch key from remote server, Error Message:" + str(msg)]
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def startRestore(backupDir,backupLogPath,dir):
|
def startRestore(backupDir,backupLogPath,dir):
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user