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 92
  • Win 40
  • Mac 35
  • Linux 17
Sep 7 Sep 6 Sep 5 Sep 4 Sep 3 Sep 2 Sep 1 Aug 31 Aug 30 Aug 29 Aug 28 Aug 27 Aug 26 Aug 25 Aug 24 Aug 23 Aug 22 Aug 21 Aug 20 Aug 19 Aug 18 Aug 17 Aug 16 Aug 15 Aug 14 Aug 13 Aug 12 Aug 11 Aug 10 Aug 9 Aug 8 Aug 7 Aug 6 Aug 5 Aug 4 Aug 3 Aug 2 Aug 1 Jul 31 Jul 30 Jul 29 Jul 28 Jul 27 Jul 26 Jul 25 Jul 24
Windows 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 3 0 2 0 1 0 3 1 0 0 1 1 0 1 6 1 2 0 0 3 1 0 0 0 1 1 0 1 1
Mac 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 1 1 0 0 0 0 0 1 1 0 1 0 0 0 3 0 1 3 1 0 0 1 1 1 0 4 0 0 1 1 1
Linux 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

SublimeOpenFileOverSSH v1.4.1

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 wndws-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 (*) option to enter a pattern like *.c *.h
  • Select the New option to create new folders and open new files

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 must support the POSIX cd, ls, printf, cat, redirection (>), globing (*) and grep (to use * to open files matching a pattern), and mkdir (to use New to create folders).

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

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.

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.4.1: Fixed silently failing to connect on Windows and added additional error handling
v1.4: Added multiplexing, menu items, 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.