ssh-to-code 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 SSH Directory Browser Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,384 @@
1
+ Metadata-Version: 2.4
2
+ Name: ssh-to-code
3
+ Version: 1.0.0
4
+ Summary: Terminal-based SSH directory browser with VS Code integration
5
+ Author-email: Rajesh <rajesh-cs18@users.noreply.github.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/rajesh-cs18/ssh-to-code
8
+ Project-URL: Bug Tracker, https://github.com/rajesh-cs18/ssh-to-code/issues
9
+ Project-URL: Repository, https://github.com/rajesh-cs18/ssh-to-code
10
+ Project-URL: Documentation, https://github.com/rajesh-cs18/ssh-to-code#readme
11
+ Keywords: ssh,vscode,terminal,directory-browser,remote-development
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Environment :: Console :: Curses
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: System Administrators
17
+ Classifier: Operating System :: POSIX :: Linux
18
+ Classifier: Operating System :: MacOS
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.7
21
+ Classifier: Programming Language :: Python :: 3.8
22
+ Classifier: Programming Language :: Python :: 3.9
23
+ Classifier: Programming Language :: Python :: 3.10
24
+ Classifier: Programming Language :: Python :: 3.11
25
+ Classifier: Programming Language :: Python :: 3.12
26
+ Classifier: Topic :: System :: Systems Administration
27
+ Classifier: Topic :: Utilities
28
+ Requires-Python: >=3.7
29
+ Description-Content-Type: text/markdown
30
+ License-File: LICENSE
31
+ Requires-Dist: paramiko>=3.0.0
32
+ Dynamic: license-file
33
+
34
+ # SSH Directory Browser
35
+
36
+ A terminal-based directory browser that lets you SSH into a remote server, navigate through directories interactively, and open selected directories directly in VS Code using the Remote-SSH extension.
37
+
38
+ ![Terminal UI](https://img.shields.io/badge/Terminal-Based-blue)
39
+ ![Python](https://img.shields.io/badge/Python-3.7+-green)
40
+ ![VS Code](https://img.shields.io/badge/VS%20Code-Remote--SSH-purple)
41
+
42
+
43
+ ## Features
44
+
45
+ - 🚀 **Interactive Terminal UI** - Browse remote directories with an intuitive curses-based interface
46
+ - 🔐 **Secure SSH Connection** - Support for key-based and password authentication
47
+ - 📂 **Visual File Browser** - Clear indicators for directories, files, executables, and symlinks
48
+ - 💻 **VS Code Integration** - Open any remote directory directly in VS Code with one keystroke
49
+ - ⚙️ **Configuration Management** - Save frequently used SSH hosts for quick access
50
+ - 🎨 **Keyboard Navigation** - Fast and efficient navigation using arrow keys
51
+
52
+ ## Requirements
53
+
54
+ - Python 3.7 or higher
55
+ - VS Code with Remote-SSH extension
56
+ - SSH access to remote server
57
+
58
+ ## Installation
59
+
60
+ ### 1. Clone the repository
61
+
62
+ ```bash
63
+ git clone <repository-url>
64
+ cd ssh-to-code
65
+ ```
66
+
67
+ ### 2. Install Python dependencies
68
+
69
+ ```bash
70
+ pip install paramiko
71
+ ```
72
+
73
+ Or use the provided requirements file:
74
+
75
+ ```bash
76
+ pip install -r requirements.txt
77
+ ```
78
+
79
+ ### 3. Make the script executable
80
+
81
+ ```bash
82
+ chmod +x ssh_dir_browser.py
83
+ ```
84
+
85
+ ### 4. (Optional) Add to PATH
86
+
87
+ For easy access from anywhere:
88
+
89
+ ```bash
90
+ # Add to your ~/.bashrc or ~/.zshrc
91
+ export PATH="$PATH:/path/to/ssh-to-code"
92
+
93
+ # Or create a symlink
94
+ sudo ln -s /path/to/ssh-to-code/ssh_dir_browser.py /usr/local/bin/ssh-browse
95
+ ```
96
+
97
+ ## Quick Start
98
+
99
+ ### Basic Usage
100
+
101
+ Connect to a remote server and start browsing:
102
+
103
+ ```bash
104
+ # Option 1: Use the wrapper script (automatically activates venv)
105
+ ./ssh-browse user@hostname
106
+
107
+ # Option 2: Activate venv manually
108
+ source venv/bin/activate
109
+ python ssh_dir_browser.py user@hostname
110
+ ```
111
+
112
+ ### With Custom Port
113
+
114
+ ```bash
115
+ ./ssh-browse user@hostname -p 2222
116
+ ```
117
+
118
+ ### With SSH Key
119
+
120
+ ```bash
121
+ ./ssh-browse user@hostname -i ~/.ssh/my_key
122
+ ```
123
+
124
+ ### Start in Specific Directory
125
+
126
+ ```bash
127
+ ./ssh-browse user@hostname --start-path /var/www
128
+ ```
129
+
130
+ ### Password Authentication
131
+
132
+ ```bash
133
+ ./ssh-browse user@hostname --password
134
+ ```
135
+
136
+ ### AWS EC2 Example
137
+
138
+ ```bash
139
+ ./ssh-browse ubuntu@ec2-12-34-56-78.compute.amazonaws.com -i ~/Downloads/aws-key.pem
140
+ ```
141
+
142
+ ## Usage
143
+
144
+ ### Keyboard Controls
145
+
146
+ | Key | Action |
147
+ |-----|--------|
148
+ | `↑` / `↓` | Navigate up/down |
149
+ | `Enter` | Open directory |
150
+ | `o` | Open current directory in VS Code |
151
+ | `n` | Create new folder |
152
+ | `h` | Go to home directory |
153
+ | `r` | Refresh directory listing |
154
+ | `q` | Quit |
155
+
156
+ ### Navigation
157
+
158
+ 1. Use arrow keys to move through the directory listing
159
+ 2. Press `Enter` to enter a directory
160
+ 3. Select `..` to go to parent directory
161
+ 4. Press `n` to create a new folder in the current directory
162
+ 5. Press `r` to refresh the directory contents
163
+ 6. Press `o` when you want to open the current directory in VS Code
164
+
165
+ ### VS Code Integration
166
+
167
+ When you press `o`, the application will:
168
+ 1. Open VS Code
169
+ 2. Connect to the remote server via Remote-SSH
170
+ 3. Open the selected directory
171
+ 4. Exit the browser
172
+
173
+ Make sure you have:
174
+ - VS Code installed with the `code` command in your PATH
175
+ - Remote-SSH extension installed in VS Code
176
+ - SSH host properly configured (or the app will help configure it)
177
+
178
+ ### Authentication Methods
179
+
180
+ The tool supports multiple authentication methods:
181
+
182
+ 1. **Unencrypted SSH Keys**: Automatic authentication
183
+ 2. **Encrypted SSH Keys**: Will prompt for passphrase (3 attempts)
184
+ 3. **Password Authentication**: Use `--password` flag
185
+ 4. **SSH Agent**: Automatically uses keys from ssh-agent
186
+
187
+ **See [AUTH_GUIDE.md](AUTH_GUIDE.md) for detailed authentication instructions**, including:
188
+ - How to handle encrypted PEM files
189
+ - What to do when you don't have the passphrase
190
+ - Using SSH agent for convenience
191
+ - Troubleshooting authentication issues
192
+ - Cloud provider specific examples (AWS, DigitalOcean, etc.)
193
+
194
+ ## Configuration
195
+
196
+ ### Saving SSH Hosts
197
+
198
+ You can save frequently used SSH connections:
199
+
200
+ ```python
201
+ from config_manager import ConfigManager
202
+
203
+ config = ConfigManager()
204
+ config.add_host(
205
+ name="myserver",
206
+ hostname="example.com",
207
+ username="myuser",
208
+ port=22,
209
+ key_file="~/.ssh/id_rsa",
210
+ default_path="/var/www"
211
+ )
212
+ ```
213
+
214
+ ### Configuration File
215
+
216
+ The configuration is stored in `~/.ssh-dir-browser.json`:
217
+
218
+ ```json
219
+ {
220
+ "version": "1.0",
221
+ "hosts": [
222
+ {
223
+ "name": "myserver",
224
+ "hostname": "example.com",
225
+ "username": "myuser",
226
+ "port": 22,
227
+ "key_file": "~/.ssh/id_rsa",
228
+ "default_path": "/var/www"
229
+ }
230
+ ],
231
+ "preferences": {
232
+ "default_start_path": "~",
233
+ "save_last_path": true
234
+ }
235
+ }
236
+ ```
237
+
238
+ ## Project Structure
239
+
240
+ ```
241
+ ssh-to-code/
242
+ ├── ssh_dir_browser.py # Main application with terminal UI
243
+ ├── ssh_handler.py # SSH connection management
244
+ ├── vscode_integration.py # VS Code Remote-SSH integration
245
+ ├── config_manager.py # Configuration file management
246
+ ├── requirements.txt # Python dependencies
247
+ ├── config.json.example # Example configuration
248
+ └── README.md # This file
249
+ ```
250
+
251
+ ## Examples
252
+
253
+ ### Example 1: Browse and Open Web Server Directory
254
+
255
+ ```bash
256
+ ./ssh_dir_browser.py webdev@myserver.com --start-path /var/www/html
257
+ ```
258
+
259
+ Navigate to your project directory and press `o` to open it in VS Code.
260
+
261
+ ### Example 2: Access Development Server with Custom Key
262
+
263
+ ```bash
264
+ ./ssh_dir_browser.py dev@staging.example.com -i ~/.ssh/staging_key -p 2222
265
+ ```
266
+
267
+ ### Example 3: Quick Access to Home Directory
268
+
269
+ ```bash
270
+ ./ssh_dir_browser.py user@server.com
271
+ # Press 'h' in the browser to go to home directory
272
+ # Navigate to desired folder
273
+ # Press 'o' to open in VS Code
274
+ ```
275
+
276
+ ## Troubleshooting
277
+
278
+ ### VS Code Command Not Found
279
+
280
+ Make sure VS Code is installed and the `code` command is in your PATH:
281
+
282
+ ```bash
283
+ # For macOS
284
+ # Open VS Code, press Cmd+Shift+P, type "shell command"
285
+ # Select "Shell Command: Install 'code' command in PATH"
286
+
287
+ # For Linux
288
+ sudo ln -s /usr/share/code/bin/code /usr/local/bin/code
289
+
290
+ # Verify installation
291
+ code --version
292
+ ```
293
+
294
+ ### Remote-SSH Extension Not Installed
295
+
296
+ Install it from VS Code:
297
+ 1. Open VS Code
298
+ 2. Go to Extensions (Cmd+Shift+X)
299
+ 3. Search for "Remote - SSH"
300
+ 4. Install the extension from Microsoft
301
+
302
+ ### SSH Connection Issues
303
+
304
+ - Verify SSH key permissions: `chmod 600 ~/.ssh/id_rsa`
305
+ - Test SSH connection manually: `ssh user@hostname`
306
+ - Check if SSH agent is running: `ssh-add -l`
307
+ - Add key to agent: `ssh-add ~/.ssh/id_rsa`
308
+
309
+ ### Python Module Not Found
310
+
311
+ Install the required dependency:
312
+
313
+ ```bash
314
+ pip install paramiko
315
+ ```
316
+
317
+ ## Advanced Features
318
+
319
+ ### Adding Custom SSH Config
320
+
321
+ The tool can automatically add SSH hosts to your `~/.ssh/config`:
322
+
323
+ ```python
324
+ from vscode_integration import VSCodeRemote
325
+
326
+ VSCodeRemote.add_ssh_host_to_config(
327
+ hostname="example.com",
328
+ username="myuser",
329
+ port=22,
330
+ key_file="~/.ssh/id_rsa",
331
+ alias="myserver"
332
+ )
333
+ ```
334
+
335
+ ### Programmatic Usage
336
+
337
+ You can use the components in your own scripts:
338
+
339
+ ```python
340
+ from ssh_handler import SSHHandler
341
+ from ssh_dir_browser import DirectoryBrowser
342
+ import curses
343
+
344
+ # Connect to server
345
+ ssh = SSHHandler("example.com", "myuser", port=22)
346
+ ssh.connect()
347
+
348
+ # Browse directories
349
+ browser = DirectoryBrowser(ssh, start_path="/var/www")
350
+ curses.wrapper(browser.run)
351
+
352
+ # Cleanup
353
+ ssh.disconnect()
354
+ ```
355
+
356
+ ## Contributing
357
+
358
+ Contributions are welcome! Feel free to:
359
+ - Report bugs
360
+ - Suggest features
361
+ - Submit pull requests
362
+
363
+ ## License
364
+
365
+ This project is open source and available under the MIT License.
366
+
367
+ ## Author
368
+
369
+ Created for seamless remote development workflow with VS Code.
370
+
371
+ ## Roadmap
372
+
373
+ - [ ] Support for bookmarking favorite directories
374
+ - [ ] Search functionality within directories
375
+ - [ ] File preview support
376
+ - [ ] Support for multiple simultaneous SSH connections
377
+ - [ ] Fuzzy search for quick navigation
378
+ - [ ] Integration with other editors (Neovim, Sublime Text, etc.)
379
+
380
+ ## Acknowledgments
381
+
382
+ - Built with [Paramiko](https://www.paramiko.org/) for SSH connectivity
383
+ - Uses Python's [curses](https://docs.python.org/3/library/curses.html) for terminal UI
384
+ - Integrates with [VS Code Remote-SSH](https://code.visualstudio.com/docs/remote/ssh)