ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Open​File​Over​SSH

by AncientRoman ST4

A lightweight Sublime Plugin that allows a File to be Opened on a Remote Machine over ssh and seamlessly edited and Saved back to the remote machine

Details

Installs

  • Total 137
  • Win 60
  • Mac 49
  • Linux 28
Oct 24 Oct 23 Oct 22 Oct 21 Oct 20 Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1 Sep 30 Sep 29 Sep 28 Sep 27 Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9
Windows 1 0 0 1 0 1 0 0 0 0 2 0 0 0 0 0 2 1 1 0 0 0 1 3 0 0 0 0 2 0 1 0 0 0 0 0 0 3 0 1 0 0 0 1 0 1
Mac 0 0 1 1 0 0 2 0 0 1 0 0 0 0 0 0 0 0 2 0 1 1 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0
Linux 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 3 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1

Readme

Source
raw.​githubusercontent.​com

SublimeOpenFileOverSSH v1.5.0

A lightweight Sublime Text 4 plugin that allows a file to be opened on a remote machine over ssh and seamlessly edited and saved back to the remote machine

Installation

This plugin works on MacOS, Linux, and Windows.

Package Control

Sublime's Package Control is the best and easiest way to install this plugin.

  1. Run the Package Control: Install Package command from the command pallet
  2. Search for and select OpenFileOverSSH
  3. Package Control will automatically install and keep this package up to date

Manual

  1. Clone or download this repo (or a versioned release) into the Sublime Packages folder.
  2. Rename the new folder to “OpenFileOverSSH”
  3. Restart Sublime Text

Usage

Trigger the remote file selection using one of these options.

  • Use the File > Open via SSH menu item
  • Run the Open File Over SSH command from the command palette
  • Press cmd-shift-o or ctrl-shift-o (you must set this up, see Key Bindings)

Once triggered, input the server details and browse/open remote files as follows.

  1. Type in the scp-like path to your server (user@server.ext:), and press enter
  2. Once the server is validated and connected, a list input will appear which allows you to choose a folder or file
  3. Continue browsing the file system on your server until you find the file you want to open
  4. Enjoy finally being able to edit a remote file in sublime (2505 students amirite)

The list input also contains various actions related to opening files.

  • Select the star (*) to enter a pattern like *.c *.h
  • Select New to create new folders and open new files
  • Select Options to edit the current file browser session's settings (See Settings for persistent changes)

Advanced

The server input can also accept paths similar to scp.

  • Use a folder path (user@server.ext:/path/to/folder/) to open the file browser at a specific folder
  • Use a file path (user@server:path/to/file.txt) to directly open a file without triggering the picker
  • The username can be omitted to use the default user (server.ext:)

The file browser shows the size of files in powers of 2 (MiB) and the number of subdirectories in a directory.

Important

You will need to setup ssh public/private key login to your remote machine so this plugin can connect to your server in the background without needing a password.

How it Works

When a remote file is opened, the contents of the file is copied into the buffer.
When the file is saved, the buffer is copied back into the remote file and sublime is given a temporary file to save to which is later deleted.
The file transferring is done using Popen's stdin and stdout to ssh, not scp.

The file selection is done by opening an ssh connection after the server is input and ls is used to populate the folder/file list on demand.

The only requirements of this plugin are the command ssh (which preferably supports OpenSSH config options) on the local machine and and a POSIX compliant shell on the remote machine. In particular, the remote machine should support the POSIX ls, printf, cat, redirection (>), test (for Path Checking), globing (*) (to use * to open files matching a pattern), and mkdir (to use New to create folders). However, if a file is opened without triggering the picker (see Advanced Usage) only cat and > are needed.

Settings

Open the settings file with one of these options.

  • Use the menu item Preferences > Package Settings > Open File Over SSH > Settings
  • Run the command pallet command Preferences: Open File Over SSH Settings
  • Open the file Packages > User > OpenFileOverSSH.sublime-settings

Hidden Files

Use the showHiddenFiles setting to show/hide hidden files in the file browser.
By default, hidden files are not shown.

Multiplexing

Ssh's multiplexing feature is used to speed up connection and authentication when browsing and saving files in short succession.
The default connection keep alive time is 5 minutes and you can change this with the multiplexing setting.
The multiplexing key accepts keep alive (ControlPersist) times in the 120s or 5m formats.
If your system doesn't support multiplexing or you'd like to disable it for security reasons, set multiplexing to false.
The default windows ssh (OpenSSH_for_Windows) does not support multiplexing, so windows has this setting set to false.

Timeout

Use the timeout setting to control ssh's connection timeout in seconds.
The default is 7 seconds.
You can set timeout to null to use ssh's default timeout which is the system's tcp timeout.

Host Key Checking

Host key checking can be controlled with the hostKeyChecking key.
This settings accepts yes, no, accept-new, or null most of which correspond to ssh's StrictHostKeyChecking setting.
null is the default and uses ssh's BatchMode default which is yes.
yes throws an error if a key does not exist or match.
no does not check or save keys.
accept-new saves new keys and only errors if a previously saved key has changed.

Path Checking

By default, remote files and folders are checked with the test command before they are opened.
You can set pathChecking to false to disable this extra check.
If path checking is disabled, any errors will occur after a path is selected instead of before.

Key Bindings

Key Bindings are disabled by default per Package Control requirements.
Enable the Open via SSH key binding by opening the key binding file in a similar manner as the settings file and copying over the disabled binding.

What's New?

v1.5: Added file size, hidden files, root dir (/), and remote error checking
v1.4.1: Fixed silently failing to connect on Windows and added additional error handling
v1.4: Added multiplexing, menu items, ssh error checking, new file/folder creation, ui updates, settings, and Package Control installation
v1.3: Support for Sublime Text 4
v1.2.2: Fixed files in subfolders being opened when a glob was used
v1.2.1: Fixed crashing sublime when a remote file was opened that did not have a new line at the end
v1.2: The wildcard (*) option opens a text input that accepts one or more glob patterns such as *.c h* and opening multiple files is wayyyy faster
v1.1: Added a file browser like interface to the Open File File Over SSH command in the command pallet
v1.0: First version with Windows support

Contributing

You can submit a PR if you'd like, but if you find a bug or would like a new feature feel free to open an Issue.
I'll respond to either as soon as I can.