Skip to content
Permalink
Browse files

Bug fix: detect non-default SSH port for WebTerminal

  • Loading branch information
usmannasir committed Nov 12, 2019
1 parent e7823cf commit 54f83c3d7887e121e4ebfa72a0e07d00fc22619c
Showing with 19 additions and 1 deletion.
  1. +19 −1 WebTerminal/CPWebSocket.py
@@ -12,6 +12,22 @@ class SSHServer(multi.Thread):
OKGREEN = '\033[92m'
ENDC = '\033[0m'

DEFAULT_PORT = 22

@staticmethod
def findSSHPort():
try:
sshData = open('/etc/ssh/sshd_config', 'r').readlines()

for items in sshData:
if items.find('Port') > -1:
if items[0] == 0:
pass
else:
SSHServer.DEFAULT_PORT = int(items.split(' ')[1])
except:
pass

def loadPublicKey(self):
pubkey = '/root/.ssh/cyberpanel.pub'
data = open(pubkey, 'r').read()
@@ -41,7 +57,7 @@ def __init__(self, websocket):
## Load Public Key
self.loadPublicKey()

self.sshclient.connect('127.0.0.1', 22, username='root', pkey=k)
self.sshclient.connect('127.0.0.1', SSHServer.DEFAULT_PORT, username='root', pkey=k)
self.shell = self.sshclient.invoke_shell(term='xterm')
self.shell.settimeout(0)

@@ -113,6 +129,8 @@ def handleClose(self):
writeToFile.write(str(os.getpid()))
writeToFile.close()

SSHServer.findSSHPort()

server = SimpleSSLWebSocketServer('0.0.0.0', '5678', WebTerminalServer, '/usr/local/lscp/conf/cert.pem', '/usr/local/lscp/conf/key.pem', version=ssl.PROTOCOL_TLSv1)

def close_sig_handler(signal, frame):

0 comments on commit 54f83c3

Please sign in to comment.
You can’t perform that action at this time.