Skip to main content

Terminal-based SSH directory browser with VS Code integration

Project description

SSH Directory Browser

A terminal-based directory browser that lets you SSH into a remote server, navigate through directories interactively, and open selected directories or .code-workspace files directly in VS Code using the Remote-SSH extension.

Terminal UI Python VS Code

Features

  • 🚀 Interactive Terminal UI - Browse remote directories with an intuitive curses-based interface
  • 🔐 Secure SSH Connection - Support for key-based and password authentication
  • 📂 Visual File Browser - Clear indicators for directories, files, executables, and symlinks
  • 💻 VS Code Integration - Open any remote directory directly in VS Code with one keystroke
  • 🧩 Workspace File Support - Open remote .code-workspace files directly in VS Code
  • ⚙️ Configuration Management - Save frequently used SSH hosts for quick access
  • 🎨 Keyboard Navigation - Fast and efficient navigation using arrow keys

Requirements

  • Python 3.7 or higher
  • VS Code with Remote-SSH extension
  • SSH access to remote server

Installation

1. Install from PyPI (recommended)

pip install ssh-to-code

2. Verify CLI installation

ssh-browse --help

3. (Optional) Install from source for development

git clone <repository-url>
cd ssh-to-code
pip install -e .

4. (Source install only) Install dependencies manually

pip install paramiko

Or use the provided requirements file:

pip install -r requirements.txt

5. (Source install only) Make the script executable

chmod +x ssh_dir_browser.py

6. (Optional, source install only) Add to PATH

For easy access from anywhere:

# Add to your ~/.bashrc or ~/.zshrc
export PATH="$PATH:/path/to/ssh-to-code"

# Or create a symlink
sudo ln -s /path/to/ssh-to-code/ssh_dir_browser.py /usr/local/bin/ssh-browse

Quick Start

Basic Usage

Connect to a remote server and start browsing:

# Installed from PyPI or pip install -e .
ssh-browse user@hostname

# If running directly from source without install:
python ssh_dir_browser.py user@hostname

With Custom Port

ssh-browse user@hostname -p 2222

With SSH Key

ssh-browse user@hostname -i ~/.ssh/my_key

Start in Specific Directory

ssh-browse user@hostname --start-path /var/www

Password Authentication

ssh-browse user@hostname --password

AWS EC2 Example

ssh-browse ubuntu@ec2-12-34-56-78.compute.amazonaws.com -i ~/Downloads/aws-key.pem

Usage

Keyboard Controls

Key Action
/ Navigate up/down
Enter Open directory
o Open current directory, or selected .code-workspace file, in VS Code
n Create new folder
h Go to home directory
r Refresh directory listing
q Quit

Navigation

  1. Use arrow keys to move through the directory listing
  2. Press Enter to enter a directory
  3. Select .. to go to parent directory
  4. Press n to create a new folder in the current directory
  5. Press r to refresh the directory contents
  6. Press o to open the current directory in VS Code
  7. Select a .code-workspace file and press o to open that workspace in VS Code

VS Code Integration

When you press o, the application will:

  1. Open VS Code
  2. Connect to the remote server via Remote-SSH
  3. Open the current directory, or the selected .code-workspace file
  4. Exit the browser

Make sure you have:

  • VS Code installed with the code command in your PATH
  • Remote-SSH extension installed in VS Code
  • SSH host properly configured (or the app will help configure it)

Authentication Methods

The tool supports multiple authentication methods:

  1. Unencrypted SSH Keys: Automatic authentication
  2. Encrypted SSH Keys: Will prompt for passphrase (3 attempts)
  3. Password Authentication: Use --password flag
  4. SSH Agent: Automatically uses keys from ssh-agent

See AUTH_GUIDE.md for detailed authentication instructions, including:

  • How to handle encrypted PEM files
  • What to do when you don't have the passphrase
  • Using SSH agent for convenience
  • Troubleshooting authentication issues
  • Cloud provider specific examples (AWS, DigitalOcean, etc.)

Configuration

Saving SSH Hosts

You can save frequently used SSH connections:

from config_manager import ConfigManager

config = ConfigManager()
config.add_host(
    name="myserver",
    hostname="example.com",
    username="myuser",
    port=22,
    key_file="~/.ssh/id_rsa",
    default_path="/var/www"
)

Configuration File

The configuration is stored in ~/.ssh-dir-browser.json:

{
  "version": "1.0",
  "hosts": [
    {
      "name": "myserver",
      "hostname": "example.com",
      "username": "myuser",
      "port": 22,
      "key_file": "~/.ssh/id_rsa",
      "default_path": "/var/www"
    }
  ],
  "preferences": {
    "default_start_path": "~",
    "save_last_path": true
  }
}

Project Structure

ssh-to-code/
├── ssh_dir_browser.py      # Main application with terminal UI
├── ssh_handler.py           # SSH connection management
├── vscode_integration.py    # VS Code Remote-SSH integration
├── config_manager.py        # Configuration file management
├── requirements.txt         # Python dependencies
├── config.json.example      # Example configuration
└── README.md               # This file

Examples

Example 1: Browse and Open Web Server Directory

./ssh_dir_browser.py webdev@myserver.com --start-path /var/www/html

Navigate to your project directory and press o to open it in VS Code.

Example 2: Access Development Server with Custom Key

./ssh_dir_browser.py dev@staging.example.com -i ~/.ssh/staging_key -p 2222

Example 3: Quick Access to Home Directory

./ssh_dir_browser.py user@server.com
# Press 'h' in the browser to go to home directory
# Navigate to desired folder
# Press 'o' to open in VS Code

Troubleshooting

VS Code Command Not Found

Make sure VS Code is installed and the code command is in your PATH:

# For macOS
# Open VS Code, press Cmd+Shift+P, type "shell command"
# Select "Shell Command: Install 'code' command in PATH"

# For Linux
sudo ln -s /usr/share/code/bin/code /usr/local/bin/code

# Verify installation
code --version

Remote-SSH Extension Not Installed

Install it from VS Code:

  1. Open VS Code
  2. Go to Extensions (Cmd+Shift+X)
  3. Search for "Remote - SSH"
  4. Install the extension from Microsoft

SSH Connection Issues

  • Verify SSH key permissions: chmod 600 ~/.ssh/id_rsa
  • Test SSH connection manually: ssh user@hostname
  • Check if SSH agent is running: ssh-add -l
  • Add key to agent: ssh-add ~/.ssh/id_rsa

Python Module Not Found

Install the required dependency:

pip install ssh-to-code

Advanced Features

Adding Custom SSH Config

The tool can automatically add SSH hosts to your ~/.ssh/config:

from vscode_integration import VSCodeRemote

VSCodeRemote.add_ssh_host_to_config(
    hostname="example.com",
    username="myuser",
    port=22,
    key_file="~/.ssh/id_rsa",
    alias="myserver"
)

Programmatic Usage

You can use the components in your own scripts:

from ssh_handler import SSHHandler
from ssh_dir_browser import DirectoryBrowser
import curses

# Connect to server
ssh = SSHHandler("example.com", "myuser", port=22)
ssh.connect()

# Browse directories
browser = DirectoryBrowser(ssh, start_path="/var/www")
curses.wrapper(browser.run)

# Cleanup
ssh.disconnect()

Contributing

Contributions are welcome! Feel free to:

  • Report bugs
  • Suggest features
  • Submit pull requests

License

This project is open source and available under the MIT License.

Author

Created for seamless remote development workflow with VS Code.

Roadmap

  • Support for bookmarking favorite directories
  • Search functionality within directories
  • File preview support
  • Support for multiple simultaneous SSH connections
  • Fuzzy search for quick navigation
  • Integration with other editors (Neovim, Sublime Text, etc.)

Acknowledgments

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ssh_to_code-1.0.1.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ssh_to_code-1.0.1-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

Details for the file ssh_to_code-1.0.1.tar.gz.

File metadata

  • Download URL: ssh_to_code-1.0.1.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for ssh_to_code-1.0.1.tar.gz
Algorithm Hash digest
SHA256 069a20f18d42eafd3a36e0dc34767cc51a8754a4dec43739df25e60b8c583e72
MD5 8fa8a50eb7eaef935318084fba5ec98c
BLAKE2b-256 ebf224f1666f4afd34b648f76b78e4d1d061d2d25e9b5a544d552adcac717552

See more details on using hashes here.

File details

Details for the file ssh_to_code-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: ssh_to_code-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 21.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for ssh_to_code-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8c21c184f081432d0a26ea7e6c0812eb9b7233dcac83101f0a8dfbff0fd38eb5
MD5 6ffdf90316f6d1b8f23dd4d5a7772c20
BLAKE2b-256 62000d4c31da734f9e38d1e0f780a7e1f71e0ea8b00e8fa77ba5aba432d0c517

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page