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
6 changes: 6 additions & 0 deletions cli/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ echo "Copying CLI files to $CLI_HOME..."
rm -rf "$CLI_HOME"
cp -r "$SCRIPT_DIR" "$CLI_HOME"

# Bundle package.json next to the CLI so it can report the real build version
# (the CLI derives its version from package.json instead of a hardcoded string).
if [ -f "$SCRIPT_DIR/../package.json" ]; then
cp "$SCRIPT_DIR/../package.json" "$CLI_HOME/package.json"
fi

# Create executable symlink
$SUDO ln -sf "$CLI_HOME/ssh-manager" "$INSTALL_DIR/ssh-manager"

Expand Down
29 changes: 24 additions & 5 deletions cli/lib/menu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,17 @@ wizard_add_server() {
echo "Set a default directory for this server (optional)."
echo "Example: /var/www/html, /home/user/app, /opt/services"
prompt_input "Default directory" "" "default_dir"


local forward_agent="n"
echo
echo "Forward your local ssh-agent to this server (optional)."
echo "Lets remote processes use your local keys — e.g. git over SSH."
print_warning "Security: anyone with root on this host can use your loaded keys"
print_warning "for the life of the connection. Only enable for servers you trust."
if prompt_yes_no "Enable SSH agent forwarding?" "n"; then
forward_agent="y"
fi

# Step 5: Review
echo
print_subheader "Step 5: Review Configuration"
Expand All @@ -198,18 +208,27 @@ wizard_add_server() {
if [ -n "$default_dir" ]; then
print_table_row "Default Dir:" "$default_dir"
fi

if [ "$forward_agent" = "y" ]; then
print_table_row "Agent Forwarding:" "enabled"
fi

echo
if prompt_yes_no "Save this configuration?" "y"; then
# Save to .env
add_server_to_env "$server_name" "$host" "$user" "$auth_type" "$auth_value" "$port" "$description"


local name_upper="$(echo "$server_name" | tr '[:lower:]' '[:upper:]')"

# Add default directory if specified
if [ -n "$default_dir" ]; then
local name_upper="$(echo "$server_name" | tr '[:lower:]' '[:upper:]')"
echo "SSH_SERVER_${name_upper}_DEFAULT_DIR=$default_dir" >> "$SSH_MANAGER_ENV"
fi


# Enable agent forwarding if opted in
if [ "$forward_agent" = "y" ]; then
echo "SSH_SERVER_${name_upper}_FORWARD_AGENT=true" >> "$SSH_MANAGER_ENV"
fi

echo
print_success "Server '$server_name' added successfully!"

Expand Down
20 changes: 18 additions & 2 deletions cli/ssh-manager
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,24 @@ source "$SCRIPT_DIR/lib/menu.sh"
source "$SCRIPT_DIR/commands/server.sh"
source "$SCRIPT_DIR/commands/tools.sh"

# Version
VERSION="3.1.0"
# Version — derived from package.json so it always reflects the real build,
# never a hardcoded literal that drifts across releases. Works both in-repo
# (cli/../package.json) and from an installed copy (package.json bundled next
# to this script by install.sh). Uses sed only, so no jq dependency.
get_cli_version() {
local pkg ver
for pkg in "$SCRIPT_DIR/../package.json" "$SCRIPT_DIR/package.json"; do
if [ -f "$pkg" ]; then
ver="$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$pkg" | head -n1)"
if [ -n "$ver" ]; then
echo "$ver"
return
fi
fi
done
echo "unknown"
}
VERSION="$(get_cli_version)"

# Show version
show_version() {
Expand Down
Loading