Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Web SSH Terminal is a self-hosted web application that provides secure SSH acces
- **Session Restoration** - Restore live sessions after a page refresh without injecting terminal input
- **Persistent tmux Sessions** - Keep remote shells and running commands alive across browser closes and WebSSH restarts, then reattach later
- **Manual Reconnect** - Reconnect from a session tab; SSH-key and Tailscale sessions can reconnect directly, while password sessions reopen the pre-filled connection form
- **Profile Launcher** - Empty terminal panes show saved profiles; key and Tailscale profiles connect immediately when no password is needed, while password-dependent profiles open pre-filled at the required field
- **Post-Connect Command Sets** - Build named, ordered command sequences and assign one to a connection or saved profile
- **Persistent Session Names** - Custom tab names are retained for persistent sessions across browsers
- **Configurable Scrollback** - Set 50 to 10,000 terminal lines and navigate them with the custom scrollbar
Expand Down
42 changes: 42 additions & 0 deletions app/key_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,48 @@ def read_key_content(user_id, key_id):
log_error(f"Error reading key content", user_id=user_id, key_id=key_id, error=str(e))
return None, f"Failed to read key: {str(e)}"


def load_key_summaries(user_id):
"""Return key metadata with a transient usability status for clients."""
keys = load_keys(user_id)
keys_dir = get_user_keys_dir(user_id)
if not keys_dir:
return [{**key, 'usable': False} for key in keys]

fernet = None
summaries = []
for key in keys:
if not isinstance(key, dict):
continue
usable = False
try:
filename = key.get('filename')
if not filename or Path(filename).name != filename:
raise ValueError('invalid key filename')

raw = (keys_dir / filename).read_bytes()
if key_encryption.is_encrypted(raw):
if fernet is None:
fernet = key_encryption.get_user_fernet(str(user_id))
raw = fernet.decrypt(raw)

identify_private_key(raw.decode('utf-8'))
usable = True
except (
OSError,
UnicodeDecodeError,
key_encryption.InvalidToken,
paramiko.PasswordRequiredException,
paramiko.SSHException,
UnsupportedPrivateKeyError,
ValueError,
TypeError,
):
pass
summaries.append({**key, 'usable': usable})
return summaries


def delete_key(user_id, key_id):
"""Delete an SSH key and its metadata for a specific user."""
try:
Expand Down
16 changes: 13 additions & 3 deletions app/socket_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
log_file_upload, log_file_download,
log_key_upload, log_key_delete,
log_tailscale_ssh_usage)
from .tailscale_ssh import validate_tailscale_ssh_access
from .tailscale_ssh import (
profile_is_authorized_for_launch,
validate_tailscale_ssh_access,
)
from .startup_commands import normalize_startup_commands
from .storage_utils import storage_lock
from . import binary_transfer, connection_pool
Expand Down Expand Up @@ -577,7 +580,14 @@ def handle_ssh_disconnect(data, current_user=None):
def handle_list_profiles(current_user=None):
"""Return list of saved connection profiles for this user."""
try:
profiles = profile_manager.load_profiles(current_user.id)
profiles = []
for stored_profile in profile_manager.load_profiles(current_user.id):
profile = dict(stored_profile)
if profile.get('auth_type') == 'tailscale':
profile['tailscale_authorized'] = (
profile_is_authorized_for_launch(current_user, profile)
)
profiles.append(profile)
emit('profiles_list', {'profiles': profiles})
except Exception as e:
log_error("Failed to load profiles", error=str(e))
Expand Down Expand Up @@ -704,7 +714,7 @@ def handle_delete_jump_host(data, current_user=None):
def handle_list_keys(current_user=None):
"""Return list of stored SSH keys for this user."""
try:
keys = key_manager.load_keys(current_user.id)
keys = key_manager.load_key_summaries(current_user.id)
emit('keys_list', {'keys': keys})
except Exception as e:
log_error("Failed to load keys", error=str(e))
Expand Down
11 changes: 11 additions & 0 deletions app/tailscale_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,14 @@ def validate_tailscale_ssh_access(user, host, remote_username):
return 'Tailscale SSH remote username is not allowed'

return None


def profile_is_authorized_for_launch(user, profile):
"""Return whether a saved profile is still allowed by current policy."""
if not isinstance(profile, dict) or profile.get('auth_type') != 'tailscale':
return True
return validate_tailscale_ssh_access(
user,
profile.get('host'),
profile.get('username'),
) is None
Binary file modified docs/screenshots/02_main_empty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
154 changes: 112 additions & 42 deletions static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1737,31 +1737,134 @@ body.broadcast-active .terminal-wrapper:not(.unassigned) {

.pane-empty {
flex: 1;
min-width: 0;
min-height: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 12px;
gap: 10px;
color: var(--text-muted);
font-size: 14px;
padding: 24px;
text-align: center;
}

.pane-empty-icon {
font-size: 48px;
flex: 0 0 auto;
font-size: 42px;
line-height: 1;
opacity: 0.4;
margin-bottom: 8px;
}

.pane-empty-text {
.profile-launcher-title {
color: var(--text-primary);
font-size: 18px;
font-weight: 700;
}

.profile-launcher-hint {
color: var(--text-secondary);
font-weight: 500;
font-size: 13px;
}

.pane-empty button {
padding: 10px 18px;
margin-top: 8px;
.profile-launcher-list {
width: min(760px, 100%);
max-height: min(48vh, 420px);
min-height: 0;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: 10px;
padding: 4px;
overflow-y: auto;
scrollbar-gutter: stable;
}

.profile-launcher-card {
min-width: 0;
min-height: var(--touch-target-min);
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
gap: 4px 10px;
padding: 12px 14px;
border: 1px solid var(--border-color);
border-radius: 9px;
background: var(--bg-secondary);
color: var(--text-primary);
font: inherit;
text-align: left;
cursor: pointer;
transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.profile-launcher-card:hover {
border-color: var(--accent-primary);
background: var(--bg-hover);
transform: translateY(-1px);
}

.profile-launcher-card:focus-visible {
outline: 2px solid var(--accent-primary);
outline-offset: 2px;
}

.profile-launcher-name,
.profile-launcher-endpoint {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

.profile-launcher-name {
font-weight: 700;
}

.profile-launcher-endpoint {
grid-column: 1;
color: var(--text-secondary);
font-family: var(--font-mono);
font-size: 11px;
}

.profile-launcher-action {
grid-column: 2;
grid-row: 1 / span 2;
align-self: center;
color: var(--text-secondary);
font-size: 11px;
white-space: nowrap;
}

.profile-launcher-action.mode-connect {
color: var(--success-color);
}

.profile-launcher-action.mode-password,
.profile-launcher-action.mode-jump-host-password {
color: var(--warning-color);
}

.profile-launcher-new {
flex: 0 0 auto;
margin-top: 2px;
}

@media (max-width: 767px) {
.profile-launcher {
justify-content: flex-start;
padding: 18px 12px;
overflow: hidden;
}

.profile-launcher-list {
width: 100%;
max-height: none;
grid-template-columns: 1fr;
}

.profile-launcher-card {
padding: 12px;
}
}

.terminal-wrapper {
Expand Down Expand Up @@ -1802,39 +1905,6 @@ body.broadcast-active .terminal-wrapper:not(.unassigned) {
}
}

.no-sessions {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
color: var(--text-secondary);
}

.no-sessions.hidden {
display: none;
}

.no-sessions-content {
text-align: center;
animation: fadeIn 0.5s ease;
}

.no-sessions-content h2 {
font-size: 28px;
font-weight: 700;
margin-bottom: 12px;
color: var(--text-primary);
background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}

.no-sessions-content p {
font-size: 15px;
color: var(--text-secondary);
}

.btn {
padding: 10px 20px;
border: none;
Expand Down
Loading
Loading