user level ssh terminal

This commit is contained in:
usmannasir
2025-05-18 14:59:41 +05:00
parent 796287ed34
commit 065eb370b3
3 changed files with 51 additions and 2 deletions

View File

@@ -885,6 +885,11 @@ local_name %s {
cmd = shlex.split(command)
subprocess.call(cmd)
command = 'systemctl restart fastapi_ssh_server.service'
cmd = shlex.split(command)
subprocess.call(cmd)
print("1,None")
return 1, 'None'

View File

@@ -37,3 +37,4 @@ asyncssh==2.21.0
python-jose==3.4.0
websockets==15.0.1
jwt
PyJWT

View File

@@ -7,6 +7,9 @@
{% get_current_language as LANGUAGE_CODE %}
<!-- Current language: {{ LANGUAGE_CODE }} -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/xterm@5.3.0/css/xterm.css">
<script src="https://cdn.jsdelivr.net/npm/xterm@5.3.0/lib/xterm.js"></script>
<style>
.cyberpanel-website-page {
/* background: #f7fafd; */
@@ -139,7 +142,47 @@
{% if not error %}
<div style="display:flex;justify-content:flex-end;gap:18px;margin-bottom:18px;">
<div style="display:flex;justify-content:flex-end;gap:18px;margin-bottom:18px;align-items:center;">
<!-- Open Terminal Button -->
<button ng-click="openWebTerminal()" type="button" class="btn btn-success"
style="min-height: 48px; padding: 0 32px; font-size: 1.13em; font-weight: 700; border-radius: 8px; box-shadow: 0 2px 8px #b2ebf2; background: linear-gradient(90deg, #00b894 60%, #17a2b8 100%); border: none; transition: background 0.2s, box-shadow 0.2s; display: flex; align-items: center; justify-content: center; margin-right: 8px;">
<span class="btn-content" style="display: flex; align-items: center; gap: 8px;"><span style="font-size: 1.2em;">🖥️</span> Open Terminal</span>
</button>
<!-- Modal for Web Terminal -->
<div id="web-terminal-modal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Web SSH Terminal</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
</div>
<div class="modal-body">
{% if is_selfsigned_ssl %}
<div class="alert alert-warning" style="margin-bottom:18px;">
<strong>Warning:</strong> Your server is using a <b>self-signed SSL certificate</b> for the web terminal.<br>
For security and browser compatibility, please issue a valid hostname SSL certificate.<br>
<a href="{{ ssl_issue_link }}" target="_blank" class="btn btn-warning" style="margin-top:10px;">Issue SSL Now</a>
</div>
{% endif %}
{% if not has_addons %}
<div style="background: #fff3cd; color: #856404; border: 1px solid #ffeeba; border-radius: 8px; padding: 18px; margin-bottom: 18px; text-align: center;">
<strong>This feature requires the CyberPanel Add-ons bundle.</strong><br>
<a href="https://cyberpanel.net/cyberpanel-addons" target="_blank" style="color: #2563eb; text-decoration: underline; font-weight: 600;">Learn more & upgrade</a>
</div>
<div style="position: relative; width: 100%; height: 400px;">
<div id="xterm-container" style="width:100%;height:400px;background:#000;"></div>
<div style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.85); display: flex; align-items: center; justify-content: center; z-index: 10; border-radius: 8px; font-size: 1.2em; color: #888; font-weight: 600;">
Web Terminal is disabled. Please upgrade to CyberPanel Add-ons to enable this feature.
</div>
</div>
{% else %}
<div id="xterm-container" style="width:100%;height:400px;background:#000;"></div>
{% endif %}
</div>
</div>
</div>
</div>
<!-- End Open Terminal Button/Modal -->
<a class="cyber-btn orange" href="/websites/{{ domain }}/manageGIT" title="Manage Git">
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" style="vertical-align:middle;margin-right:7px;"><circle cx="10" cy="10" r="9" stroke="#ff9800" stroke-width="2"/><path d="M7 13L13 7M13 13V7H7" stroke="#ff9800" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
{% trans "Manage Git" %}
@@ -152,7 +195,7 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" style="vertical-align:middle;margin-right:7px;"><rect x="3" y="7" width="14" height="10" rx="2" stroke="#00b894" stroke-width="2"/><path d="M7 11V9C7 7.89543 7.89543 7 9 7H11C12.1046 7 13 7.89543 13 9V11" stroke="#00b894" stroke-width="2"/></svg>
{% trans "Set up SSH/SFTP Access" %}
</a>
<a class="cyber-btn purple" href="https://go.cyberpanel.net/StessTest" title="">
<a class="cyber-btn purple" href="https://cyberpanel.net/server-load-tester" title="">
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" style="vertical-align:middle;margin-right:7px;"><circle cx="10" cy="10" r="8" stroke="#8e44ad" stroke-width="2"/><path d="M10 10V5" stroke="#8e44ad" stroke-width="2" stroke-linecap="round"/><path d="M10 10L13 13" stroke="#8e44ad" stroke-width="2" stroke-linecap="round"/></svg>
{% trans "Stress Test" %}
</a>