mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-05-11 09:27:34 +02:00
726 lines
20 KiB
HTML
726 lines
20 KiB
HTML
{% extends "baseTemplate/index.html" %}
|
|
{% load i18n %}
|
|
{% block title %}{% trans "Secure SSH - CyberPanel" %}{% endblock %}
|
|
|
|
{% block header_scripts %}
|
|
<style>
|
|
.modern-container {
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
padding: 2rem;
|
|
}
|
|
|
|
.page-header {
|
|
text-align: center;
|
|
margin-bottom: 3rem;
|
|
padding: 3rem 0;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
border-radius: 20px;
|
|
animation: fadeInDown 0.5s ease-out;
|
|
position: relative;
|
|
overflow: hidden;
|
|
color: white;
|
|
}
|
|
|
|
.page-header::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: -50%;
|
|
right: -50%;
|
|
width: 200%;
|
|
height: 200%;
|
|
background: radial-gradient(circle at 70% 30%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
|
|
animation: rotate 30s linear infinite;
|
|
}
|
|
|
|
@keyframes rotate {
|
|
from { transform: rotate(0deg); }
|
|
to { transform: rotate(360deg); }
|
|
}
|
|
|
|
@keyframes fadeInDown {
|
|
from {
|
|
opacity: 0;
|
|
transform: translateY(-20px);
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
transform: translateY(0);
|
|
}
|
|
}
|
|
|
|
@keyframes fadeInUp {
|
|
from {
|
|
opacity: 0;
|
|
transform: translateY(20px);
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
transform: translateY(0);
|
|
}
|
|
}
|
|
|
|
.header-content {
|
|
position: relative;
|
|
z-index: 1;
|
|
}
|
|
|
|
.page-title {
|
|
font-size: 2.5rem;
|
|
font-weight: 700;
|
|
margin-bottom: 1rem;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 1rem;
|
|
}
|
|
|
|
.ssh-icon {
|
|
width: 60px;
|
|
height: 60px;
|
|
background: rgba(255, 255, 255, 0.2);
|
|
backdrop-filter: blur(10px);
|
|
border-radius: 12px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
|
}
|
|
|
|
.page-subtitle {
|
|
font-size: 1.125rem;
|
|
color: rgba(255, 255, 255, 0.9);
|
|
max-width: 700px;
|
|
margin: 0 auto;
|
|
line-height: 1.6;
|
|
}
|
|
|
|
.docs-link {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
color: rgba(255, 255, 255, 0.9);
|
|
text-decoration: none;
|
|
padding: 0.5rem 1rem;
|
|
background: rgba(255, 255, 255, 0.1);
|
|
border-radius: 8px;
|
|
transition: all 0.3s ease;
|
|
margin-top: 1rem;
|
|
}
|
|
|
|
.docs-link:hover {
|
|
background: rgba(255, 255, 255, 0.2);
|
|
color: white;
|
|
transform: translateY(-2px);
|
|
}
|
|
|
|
/* Tab Navigation */
|
|
.tab-nav {
|
|
display: flex;
|
|
gap: 1rem;
|
|
margin-bottom: 2rem;
|
|
background: white;
|
|
padding: 1rem;
|
|
border-radius: 12px;
|
|
box-shadow: 0 1px 3px rgba(0,0,0,0.05);
|
|
animation: fadeInUp 0.5s ease-out 0.1s;
|
|
animation-fill-mode: both;
|
|
}
|
|
|
|
.tab-btn {
|
|
flex: 1;
|
|
padding: 1rem;
|
|
background: #f8f9ff;
|
|
border: 2px solid transparent;
|
|
border-radius: 10px;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 0.75rem;
|
|
font-weight: 500;
|
|
color: #64748b;
|
|
}
|
|
|
|
.tab-btn:hover {
|
|
background: #e8e9ff;
|
|
border-color: #667eea;
|
|
}
|
|
|
|
.tab-btn.active {
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
border-color: transparent;
|
|
}
|
|
|
|
.tab-content {
|
|
display: none;
|
|
animation: fadeInUp 0.3s ease-out;
|
|
}
|
|
|
|
.tab-content.active {
|
|
display: block;
|
|
}
|
|
|
|
/* Main Panel */
|
|
.main-panel {
|
|
background: white;
|
|
border-radius: 16px;
|
|
box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 10px 40px rgba(0,0,0,0.08);
|
|
border: 1px solid #e8e9ff;
|
|
overflow: hidden;
|
|
animation: fadeInUp 0.5s ease-out 0.2s;
|
|
animation-fill-mode: both;
|
|
}
|
|
|
|
.panel-header {
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
padding: 1.5rem 2rem;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
}
|
|
|
|
.panel-title {
|
|
font-size: 1.25rem;
|
|
font-weight: 600;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.75rem;
|
|
}
|
|
|
|
.panel-icon {
|
|
width: 32px;
|
|
height: 32px;
|
|
background: rgba(255,255,255,0.2);
|
|
border-radius: 8px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.panel-content {
|
|
padding: 2rem;
|
|
}
|
|
|
|
/* Form Styles */
|
|
.form-group {
|
|
margin-bottom: 1.5rem;
|
|
}
|
|
|
|
.form-label {
|
|
display: block;
|
|
font-weight: 600;
|
|
color: #334155;
|
|
margin-bottom: 0.5rem;
|
|
font-size: 0.875rem;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.05em;
|
|
}
|
|
|
|
.form-control {
|
|
width: 100%;
|
|
padding: 0.75rem 1rem;
|
|
border: 2px solid #e8e9ff;
|
|
border-radius: 10px;
|
|
font-size: 0.9375rem;
|
|
transition: all 0.3s ease;
|
|
background: #f8f9ff;
|
|
}
|
|
|
|
.form-control:focus {
|
|
outline: none;
|
|
border-color: #667eea;
|
|
background: white;
|
|
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
|
|
}
|
|
|
|
/* Custom Switch */
|
|
.switch {
|
|
position: relative;
|
|
display: inline-block;
|
|
width: 50px;
|
|
height: 26px;
|
|
}
|
|
|
|
.switch input {
|
|
opacity: 0;
|
|
width: 0;
|
|
height: 0;
|
|
}
|
|
|
|
.slider {
|
|
position: absolute;
|
|
cursor: pointer;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background-color: #cbd5e1;
|
|
transition: .4s;
|
|
border-radius: 26px;
|
|
}
|
|
|
|
.slider:before {
|
|
position: absolute;
|
|
content: "";
|
|
height: 18px;
|
|
width: 18px;
|
|
left: 4px;
|
|
bottom: 4px;
|
|
background-color: white;
|
|
transition: .4s;
|
|
border-radius: 50%;
|
|
}
|
|
|
|
input:checked + .slider {
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
}
|
|
|
|
input:checked + .slider:before {
|
|
transform: translateX(24px);
|
|
}
|
|
|
|
.switch-wrapper {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 1rem;
|
|
}
|
|
|
|
/* Buttons */
|
|
.btn-primary {
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
padding: 0.75rem 2rem;
|
|
border-radius: 10px;
|
|
font-weight: 500;
|
|
font-size: 0.9375rem;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
border: none;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
|
|
}
|
|
|
|
.btn-secondary {
|
|
background: #f3f4f6;
|
|
color: #4b5563;
|
|
padding: 0.75rem 2rem;
|
|
border-radius: 10px;
|
|
font-weight: 500;
|
|
font-size: 0.9375rem;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
border: none;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
}
|
|
|
|
.btn-secondary:hover {
|
|
background: #e5e7eb;
|
|
transform: translateY(-2px);
|
|
}
|
|
|
|
/* SSH Keys Table */
|
|
.keys-table {
|
|
width: 100%;
|
|
background: white;
|
|
border-radius: 8px;
|
|
overflow: hidden;
|
|
border: 1px solid #e8e9ff;
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.keys-table thead {
|
|
background: #f8f9ff;
|
|
}
|
|
|
|
.keys-table th {
|
|
padding: 1rem;
|
|
text-align: left;
|
|
font-weight: 600;
|
|
color: #475569;
|
|
font-size: 0.75rem;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.05em;
|
|
border-bottom: 1px solid #e8e9ff;
|
|
}
|
|
|
|
.keys-table td {
|
|
padding: 1rem;
|
|
border-bottom: 1px solid #f1f5f9;
|
|
color: #334155;
|
|
font-size: 0.875rem;
|
|
}
|
|
|
|
.keys-table tbody tr {
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
.keys-table tbody tr:hover {
|
|
background: #f8f9ff;
|
|
}
|
|
|
|
.key-user {
|
|
font-weight: 600;
|
|
color: #1e293b;
|
|
}
|
|
|
|
.key-value {
|
|
font-family: 'Monaco', 'Consolas', monospace;
|
|
font-size: 0.75rem;
|
|
color: #64748b;
|
|
max-width: 300px;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.btn-delete {
|
|
background: #fee2e2;
|
|
color: #ef4444;
|
|
width: 32px;
|
|
height: 32px;
|
|
border-radius: 6px;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
cursor: pointer;
|
|
transition: all 0.2s ease;
|
|
font-weight: 700;
|
|
border: none;
|
|
}
|
|
|
|
.btn-delete:hover {
|
|
background: #ef4444;
|
|
color: white;
|
|
transform: scale(1.1);
|
|
}
|
|
|
|
/* Textarea */
|
|
.key-textarea {
|
|
width: 100%;
|
|
padding: 1rem;
|
|
border: 2px solid #e8e9ff;
|
|
border-radius: 10px;
|
|
font-family: 'Monaco', 'Consolas', monospace;
|
|
font-size: 0.875rem;
|
|
background: #f8f9ff;
|
|
transition: all 0.3s ease;
|
|
resize: vertical;
|
|
min-height: 120px;
|
|
}
|
|
|
|
.key-textarea:focus {
|
|
outline: none;
|
|
border-color: #667eea;
|
|
background: white;
|
|
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
|
|
}
|
|
|
|
/* Alerts */
|
|
.alert {
|
|
padding: 1rem 1.5rem;
|
|
border-radius: 10px;
|
|
margin: 1rem 0;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.75rem;
|
|
animation: fadeInUp 0.3s ease-out;
|
|
}
|
|
|
|
.alert-warning {
|
|
background: #fef3c7;
|
|
color: #92400e;
|
|
border: 1px solid #fde68a;
|
|
}
|
|
|
|
.alert-success {
|
|
background: #d1fae5;
|
|
color: #065f46;
|
|
border: 1px solid #a7f3d0;
|
|
}
|
|
|
|
.alert-danger {
|
|
background: #fee2e2;
|
|
color: #991b1b;
|
|
border: 1px solid #fecaca;
|
|
}
|
|
|
|
.alert-icon {
|
|
font-size: 1.25rem;
|
|
}
|
|
|
|
/* Loading spinner */
|
|
.loading-spinner {
|
|
width: 20px;
|
|
height: 20px;
|
|
border: 2px solid #f3f3f3;
|
|
border-top: 2px solid #667eea;
|
|
border-radius: 50%;
|
|
animation: spin 1s linear infinite;
|
|
display: inline-block;
|
|
}
|
|
|
|
@keyframes spin {
|
|
0% { transform: rotate(0deg); }
|
|
100% { transform: rotate(360deg); }
|
|
}
|
|
|
|
/* Empty State */
|
|
.empty-state {
|
|
text-align: center;
|
|
padding: 3rem;
|
|
color: #64748b;
|
|
}
|
|
|
|
.empty-icon {
|
|
font-size: 3rem;
|
|
color: #94a3b8;
|
|
margin-bottom: 1rem;
|
|
}
|
|
|
|
.empty-text {
|
|
font-size: 0.875rem;
|
|
color: #64748b;
|
|
}
|
|
|
|
/* Responsive */
|
|
@media (max-width: 768px) {
|
|
.modern-container {
|
|
padding: 1rem;
|
|
}
|
|
|
|
.page-title {
|
|
font-size: 2rem;
|
|
}
|
|
|
|
.tab-nav {
|
|
flex-direction: column;
|
|
}
|
|
|
|
.form-row {
|
|
flex-direction: column;
|
|
}
|
|
|
|
.panel-content {
|
|
padding: 1rem;
|
|
}
|
|
|
|
.key-value {
|
|
max-width: 150px;
|
|
}
|
|
}
|
|
</style>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
{% load static %}
|
|
{% get_current_language as LANGUAGE_CODE %}
|
|
<!-- Current language: {{ LANGUAGE_CODE }} -->
|
|
|
|
<div class="modern-container" ng-controller="secureSSHCTRL">
|
|
<!-- Page Header -->
|
|
<div class="page-header">
|
|
<div class="header-content">
|
|
<div class="page-title">
|
|
<div class="ssh-icon">
|
|
<i class="fas fa-terminal fa-2x"></i>
|
|
</div>
|
|
{% trans "Secure SSH" %}
|
|
</div>
|
|
<p class="page-subtitle">
|
|
{% trans "Secure and harden your SSH configurations to protect your server from unauthorized access." %}
|
|
</p>
|
|
<a href="http://go.cyberpanel.net/ssh-docs" target="_blank" class="docs-link">
|
|
<i class="fas fa-book"></i>
|
|
{% trans "SSH Documentation" %}
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Tab Navigation -->
|
|
<div class="tab-nav">
|
|
<div class="tab-btn active" onclick="switchTab('basic', this)">
|
|
<i class="fas fa-cog"></i>
|
|
<span>{% trans "Basic Settings" %}</span>
|
|
</div>
|
|
<div class="tab-btn" onclick="switchTab('keys', this)">
|
|
<i class="fas fa-key"></i>
|
|
<span>{% trans "SSH Keys" %}</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Basic Settings Tab -->
|
|
<div id="basic-tab" class="tab-content active">
|
|
<div class="main-panel">
|
|
<div class="panel-header">
|
|
<div class="panel-title">
|
|
<div class="panel-icon">
|
|
<i class="fas fa-cog"></i>
|
|
</div>
|
|
{% trans "Basic SSH Settings" %}
|
|
</div>
|
|
<div ng-show="!secureSSHLoading" class="loading-spinner"></div>
|
|
</div>
|
|
|
|
<div class="panel-content">
|
|
<form>
|
|
<div class="form-group">
|
|
<label class="form-label">{% trans "SSH Port" %}</label>
|
|
<input type="text" class="form-control" ng-model="sshPort"
|
|
placeholder="{% trans 'Default: 22' %}"
|
|
pattern="[0-9]*" required>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="form-label">{% trans "Permit Root Login" %}</label>
|
|
<div class="switch-wrapper">
|
|
<label class="switch">
|
|
<input type="checkbox" id="rootLogin">
|
|
<span class="slider"></span>
|
|
</label>
|
|
<span>{% trans "Allow root user to login via SSH" %}</span>
|
|
</div>
|
|
|
|
<div class="alert alert-warning" style="margin-top: 1rem;">
|
|
<i class="fas fa-exclamation-triangle alert-icon"></i>
|
|
<span>{% trans "Before disabling root login, make sure you have another account with sudo privileges on server." %}</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group" style="margin-top: 2rem;">
|
|
<button type="button" ng-click="saveChanges()" class="btn-primary">
|
|
<i class="fas fa-save"></i>
|
|
{% trans "Save Changes" %}
|
|
</button>
|
|
</div>
|
|
|
|
<!-- Status Messages -->
|
|
<div ng-hide="couldNotSave" class="alert alert-danger">
|
|
<i class="fas fa-exclamation-circle alert-icon"></i>
|
|
<span>{% trans "Error message:" %} {$ errorMessage $}</span>
|
|
</div>
|
|
|
|
<div ng-hide="detailsSaved" class="alert alert-success">
|
|
<i class="fas fa-check-circle alert-icon"></i>
|
|
<span>{% trans "SSH Configurations Saved Successfully." %}</span>
|
|
</div>
|
|
|
|
<div ng-hide="couldNotConnect" class="alert alert-danger">
|
|
<i class="fas fa-exclamation-circle alert-icon"></i>
|
|
<span>{% trans "Could not connect. Please refresh this page." %}</span>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- SSH Keys Tab -->
|
|
<div id="keys-tab" class="tab-content">
|
|
<div class="main-panel">
|
|
<div class="panel-header">
|
|
<div class="panel-title">
|
|
<div class="panel-icon">
|
|
<i class="fas fa-key"></i>
|
|
</div>
|
|
{% trans "SSH Keys Management" %}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="panel-content">
|
|
<!-- Keys Table -->
|
|
<div ng-if="records.length > 0">
|
|
<table class="keys-table">
|
|
<thead>
|
|
<tr>
|
|
<th>{% trans "User Name" %}</th>
|
|
<th>{% trans "Key" %}</th>
|
|
<th>{% trans "Action" %}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr ng-repeat="record in records track by $index">
|
|
<td class="key-user">{$ record.userName $}</td>
|
|
<td class="key-value" title="{$ record.key $}">{$ record.key $}</td>
|
|
<td>
|
|
<button type="button" ng-click="deleteKey(record.key)" class="btn-delete"
|
|
title="{% trans 'Delete Key' %}">
|
|
<i class="fas fa-times"></i>
|
|
</button>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<!-- Empty State -->
|
|
<div ng-if="records.length == 0" class="empty-state">
|
|
<i class="fas fa-key empty-icon"></i>
|
|
<p class="empty-text">{% trans "No SSH keys found. Add your first key below." %}</p>
|
|
</div>
|
|
|
|
<!-- Add Key Form -->
|
|
<div ng-hide="keyBox" style="margin-top: 2rem;">
|
|
<label class="form-label">{% trans "Public Key" %}</label>
|
|
<textarea ng-model="keyData"
|
|
class="key-textarea"
|
|
placeholder="{% trans 'Paste your public key here (e.g., ssh-rsa AAAAB3...)' %}"></textarea>
|
|
</div>
|
|
|
|
<!-- Action Buttons -->
|
|
<div style="margin-top: 1.5rem;">
|
|
<button ng-hide="showKeyBox" type="button" ng-click="addKey()" class="btn-primary">
|
|
<i class="fas fa-plus"></i>
|
|
{% trans "Add Key" %}
|
|
</button>
|
|
|
|
<button ng-hide="saveKeyBtn" type="button" ng-click="saveKey()" class="btn-primary">
|
|
<i class="fas fa-save"></i>
|
|
{% trans "Save Key" %}
|
|
</button>
|
|
</div>
|
|
|
|
<!-- Status Messages -->
|
|
<div ng-hide="keyDeleted" class="alert alert-success" style="margin-top: 1rem;">
|
|
<i class="fas fa-check-circle alert-icon"></i>
|
|
<span>{% trans "SSH Key Deleted Successfully" %}</span>
|
|
</div>
|
|
|
|
<div ng-hide="couldNotConnect" class="alert alert-danger" style="margin-top: 1rem;">
|
|
<i class="fas fa-exclamation-circle alert-icon"></i>
|
|
<span>{% trans "Could not connect. Please refresh this page." %}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function switchTab(tabName, element) {
|
|
// Hide all tabs
|
|
document.querySelectorAll('.tab-content').forEach(tab => {
|
|
tab.classList.remove('active');
|
|
});
|
|
|
|
// Remove active class from all buttons
|
|
document.querySelectorAll('.tab-btn').forEach(btn => {
|
|
btn.classList.remove('active');
|
|
});
|
|
|
|
// Show selected tab
|
|
document.getElementById(tabName + '-tab').classList.add('active');
|
|
element.classList.add('active');
|
|
}
|
|
</script>
|
|
|
|
{% endblock %} |