fix missing password

This commit is contained in:
Usman Nasir
2020-04-27 21:01:28 +05:00
parent cd524db544
commit b8ef19283f
2 changed files with 16 additions and 10 deletions

View File

@@ -219,13 +219,16 @@ class backupSchedule:
## IP of Remote server.
data = open(destinations,'r').readlines()
ipAddress = data[0].strip("\n")
port = data[1].strip("\n")
user = data[2].strip("\n")
destinations = backupUtilities.destinationsPath
data = json.loads(open(destinations, 'r').read())
port = data['port']
# Set the user to root if not specified aka empty
user = user if bool(user) is not False else 'root'
try:
user = data['user']
except:
user = 'root'
ipAddress = data['ipAddress']
## IPAddress of local server

View File

@@ -1042,7 +1042,7 @@ class backupUtilities:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + "[checkIfHostIsUp]")
@staticmethod
def checkConnection(IPAddress, password, port='22', user='root'):
def checkConnection(IPAddress, port='22', user='root'):
try:
try:
@@ -1061,9 +1061,12 @@ class backupUtilities:
expectation.append(pexpect.EOF)
expectation.append(pexpect.TIMEOUT)
checkConn = pexpect.spawn(
"sudo ssh -i /root/.ssh/cyberpanel -o StrictHostKeyChecking=no -p " + port + ' ' + user + "@" + IPAddress,
timeout=3)
command = "sudo ssh -i /root/.ssh/cyberpanel -o StrictHostKeyChecking=no -p " + port + ' ' + user + "@" + IPAddress
if os.path.exists(ProcessUtilities.debugPath):
logging.CyberCPLogFileWriter.writeToFile(command)
checkConn = pexpect.spawn(command,timeout=3)
index = checkConn.expect(expectation)
if index == 0: