Remote file editing

From Earlham CS Department
Revision as of 14:03, 21 January 2020 by Craigje (talk | contribs) (Text editor apps)
Jump to navigation Jump to search

It's often good to be able to edit files remotely in an editor. This is much superior (for advanced projects) to Jupyter Notebooks for most purposes. Here are some instructions as to how.

At the terminal

Use vi, vim, nano, or some other editor at the terminal for editing if you want simplicity and do a lot of admin work.

Text editor apps

Generally, a text editor will have either a built-in feature or an extension that supports adding SFTP (secure FTP) servers. You'll want to add tools, hopper, or both to your editor.

A common pattern is to:

  • download the software (links with each editor),
  • add your username and password or ssh key for the server you want,
  • connect,
  • and save a document to verify that your connection works.

Atom (Open source, OS X, Linux, Windows)

  • Download and install.
  • Install the FTP-remote-edit extension.
  • Set your password. This is for your local account only.
  • Add your servers.
  • Use the SSH port (22) and your ssh key or password.
  • You can right-click > Edit Servers at any time to add, remove, or change servers.

Sublime (Commercial (possible to use without cost), OS X, Linux, Windows)

  • Download and install.
  • Tools > Command Palette > type "package" > Package Control: Install Package > type "sftp" > click first entry
  • Now go to File > SFTP/FTP to do tasks like setting up and browsing servers

BBEdit (Was TextWrangler, commercial (with free mode), OS X, installed on the CST Macs)

  • Download and install.
  • From the File menu choose "Open from FTP/SFTP Server" and configure tools.cs.earlham.edu as a server.

Notepad++ for Windows

  • Download and install. You're almost certain to want the 64-bit version.
  • Plugins > Manage plugins > "NppFTP" (if it's not already installed)
  • Plugins > NppFTP > Open NppFTP > gear ("Settings") > Profile settings > Add new

Visual Studio Code (Windows)

  • Download and install
  • Also make sure that you have OpenSSH installed, which comes standard with most versions of Windows 10 now, by opening Command Prompt or PowerShell and running ssh
    • Also, if you have not already, generate an RSA key and run ssh-keygen and then ssh-copy-id USERNAME@server
  • Click on the Extension Tab, and search for "Remote Development Extension Pack"
  • Click Install
  • Reload the window if prompted
  • If it does not prompt you to, open your ssh configs by pressing CTRL+p, then typing ">Remote-SSH: Open Configuration File", and then pressing enter
  • The next steps depend on whether you want to work on Tools and/or the Cluster
    • Cluster
      • NOTE: As of September 2019, Remote Editing for VSCode does not currently support CentOS versions under 7, so it cannot be run on Hopper.
      • Add the following code snippet to your ssh config file, replacing USERNAME with your username and the path to your ssh.exe if it is not in System32.
Host pollock bronte
   HostName %h.cluster.earlham.edu
   ProxyCommand C:\Windows\System32\OpenSSH\ssh.exe hopper.cluster.earlham.edu nc %h %p
   User USERNAME
   DynamicForward 1082

Host hopper.cluster.earlham.edu
    User USERNAME
      • NOTE: you can add more than just bronte and pollock to the Host line; you just need to separate them by spaces. The config will work the same as long as you've spelled everything correctly!
    • Tools
      • Add the following code snippet to your ssh config file.
Host tools
    HostName tools.cs.earlham.edu
    User USERNAME
  • After you have done one or both of those instructions, save your config, navigate to the remote editing tab on the left side of the screen, and hit the refresh button.\
  • If everything worked correctly, whatever servers you added should appear on the list