mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-12 16:26:12 +01:00
Run CyberPanel as user cyberpanel
This commit is contained in:
@@ -5,73 +5,18 @@ from CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||
import time
|
||||
from backupUtilities import backupUtilities
|
||||
import signal
|
||||
import shlex
|
||||
import subprocess
|
||||
|
||||
def verifyHostKey(IPAddress):
|
||||
try:
|
||||
backupUtilities.host_key_verification(IPAddress)
|
||||
def verifyHostKey(directory):
|
||||
command = "sudo chmod -R 775 " + directory
|
||||
|
||||
password = "hello"
|
||||
print command
|
||||
|
||||
expectation = []
|
||||
cmd = shlex.shlex(command)
|
||||
|
||||
expectation.append("continue connecting (yes/no)?")
|
||||
expectation.append("password:")
|
||||
|
||||
setupSSHKeys = pexpect.spawn("ssh root@" + IPAddress)
|
||||
|
||||
index = setupSSHKeys.expect(expectation)
|
||||
|
||||
if index == 0:
|
||||
setupSSHKeys.sendline("yes")
|
||||
|
||||
setupSSHKeys.expect("password:")
|
||||
setupSSHKeys.sendline(password)
|
||||
|
||||
expectation = []
|
||||
|
||||
expectation.append("password:")
|
||||
expectation.append(pexpect.EOF)
|
||||
|
||||
|
||||
innerIndex = setupSSHKeys.expect(expectation)
|
||||
|
||||
if innerIndex == 0:
|
||||
setupSSHKeys.kill(signal.SIGTERM)
|
||||
return [1, "None"]
|
||||
elif innerIndex == 1:
|
||||
setupSSHKeys.kill(signal.SIGTERM)
|
||||
return [1, "None"]
|
||||
|
||||
elif index == 1:
|
||||
|
||||
setupSSHKeys.expect("password:")
|
||||
setupSSHKeys.sendline(password)
|
||||
|
||||
expectation = []
|
||||
|
||||
expectation.append("password:")
|
||||
expectation.append(pexpect.EOF)
|
||||
|
||||
innerIndex = setupSSHKeys.expect(expectation)
|
||||
|
||||
if innerIndex == 0:
|
||||
setupSSHKeys.kill(signal.SIGTERM)
|
||||
return [1, "None"]
|
||||
elif innerIndex == 1:
|
||||
setupSSHKeys.kill(signal.SIGTERM)
|
||||
return [1, "None"]
|
||||
|
||||
|
||||
except pexpect.TIMEOUT, msg:
|
||||
logging.writeToFile("Timeout [verifyHostKey]")
|
||||
return [0,"Timeout [verifyHostKey]"]
|
||||
except pexpect.EOF, msg:
|
||||
logging.writeToFile("EOF [verifyHostKey]")
|
||||
return [0,"EOF [verifyHostKey]"]
|
||||
except BaseException, msg:
|
||||
logging.writeToFile(str(msg) + " [verifyHostKey]")
|
||||
return [0,str(msg)+" [verifyHostKey]"]
|
||||
res = subprocess.call(cmd)
|
||||
|
||||
|
||||
|
||||
print verifyHostKey("23.95.216.56")
|
||||
print verifyHostKey("/home/ssl.cyberpanel.net")
|
||||
Reference in New Issue
Block a user