-
Notifications
You must be signed in to change notification settings - Fork 52
feat: Add "Paste SSH" feature for parsing SSH commands from clipboard and add as a new server #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
While this PR doesn't directly implement server duplication, it provides a complementary solution that addresses similar use cases as requested in issue #14 "Feature Request: Duplicate/Clone hosts". What this PR addsThis PR introduces the "Paste SSH" feature (keybinding
How it helps with bulk host management
Example workflow# Copy from your documentation:
ssh user@prod-server-01.example.com -p 2222
# Press 'v' in lazyssh, review/edit, save
ssh user@prod-server-02.example.com -p 2222
# Press 'v' again for the next server |
46e59e7
to
ad36009
Compare
Hi @Adembc, I just rebased this PR against the most recent |
Marked as draft to wait for #48 |
ad36009
to
9839e74
Compare
6304319
to
ee756e3
Compare
- Parse SSH commands from clipboard into domain.Server struct - Support standard SSH flags (-p, -i, -l, -A, -X, -Y, -C, -4, -6, etc.) - Support SSH -o options mapping to ssh_config fields - Handle multiline commands with backslash continuation - Extract lazyssh metadata (alias and tags) from comments - Ignore regular comments (lines starting with #) - Add comprehensive test coverage for various SSH command patterns
- GenerateUniqueAlias: Handle duplicate aliases with smart numbering - Extract base name from aliases with existing suffixes (e.g., "123_1" -> "123") - Find highest suffix and increment (e.g., "123_1" -> "123_2", not "123_1_1") - GenerateSmartAlias: Create intelligent aliases from host/user/port - Simplify domain names (remove www, extract meaningful parts) - Handle IP addresses appropriately - Skip common usernames (root, ubuntu, ec2-user, centos, azureuser, etc.) - Append non-standard ports to alias - Add comprehensive test coverage for edge cases
- Add IsIPAddress public function for shared IP validation - Add GetFieldValidatorsWithContext for context-aware validation - Implement duplicate alias validation with support for edit mode - Share IP validation logic between alias generation and validation - Add comprehensive test coverage for IPv4 and IPv6 addresses - Add tests for duplicate alias validation scenarios
- Add 'v' keybinding to paste and parse SSH commands from clipboard - Parse SSH command using the new SSH parser - Auto-generate unique alias if duplicate detected - Open server form in Add mode with parsed data - Update UI components to show 'v' keybinding: - Hint bar: Add 'v' to keybinding hints - Status bar: Add 'v' Paste SSH to navigation help - Server details: Add 'v' to commands list - Support for clipboard integration via github.com/atotto/clipboard - Add getExistingAliases helper to retrieve all current aliases
- Add initialData field to ServerForm struct for pre-filling forms - Add SetInitialData method to set pre-fill data separately from original - Update getDefaultValues to differentiate between Edit mode (original) and Add mode (initialData) - Fix issue where pasted servers were incorrectly treated as updates - Ensure proper mode handling when creating new servers from paste - Set default port to 22 when port is 0 or unspecified
- Update BuildSSHCommand to include alias and tags as comment - Format: # lazyssh-alias:<alias> tags:<tag1,tag2,...> - Add test coverage for BuildSSHCommand with tags - Enable round-trip capability (copy → paste preserves metadata)
ee756e3
to
6b5ddfa
Compare
Summary
v
complements the existing Copy SSH (c
) functionalityChanges
Features
Supported SSH Command Formats
ssh user@host
ssh host
(uses current user)ssh user@host -p 2222
ssh user@host -i ~/.ssh/custom_key
ssh -p 2222 -i ~/.ssh/custom_key -J jump@proxy user@host
ssh -o StrictHostKeyChecking=no user@host
# lazyssh-alias:myserver tags:prod,web
Supported SSH Flags
-p
Port specification-i
Identity file (multiple supported)-l
Login name-J
ProxyJump-L
Local forwarding-R
Remote forwarding-D
Dynamic forwarding-A/-a
Agent forwarding-X/-Y
X11 forwarding-C
Compression-4/-6
IP version forcing-o
SSH options (40+ options supported)Smart Alias Generation
server
→server_1
→server_2
(notserver_1_1
)Smart Defaults
22
(when not specified)Test Plan
Technical Details
Closes #14