Remote "Networked" Editing
At the April 16th meeting (2014) of the Framingham Makerspace RPi group, the group leader told us that he uses a text editor with a built-in secure ftp (sftp) capability so he can use his main computer to do the editing with his favorite editor and then automatically transfer the finished file back to the "remote" RPi, even if it is just across the table. That lets him run the RPi in "headless" mode (without a monitor, keyboard and mouse connected). Headless setups are convenient when the RPi is part of a project that does steady sensor or controller work, sort of "embedded" computing instead of having the RPi as a desktop substitute. The alternative, using the built-in vi(m) editor on the RPi through a SSH connection, is good enough, in his opinion, in a pinch. For daily development work, he likes his comfortable text editor and it may not be available on the RPi.
Now, I am not going to use his recommended Notepad++ because that is a Windows program, and I don't use a Macintosh which he mentioned, so I decided to check into the possibilities for the Kate text editor from the KDE community that runs on my Kubuntu laptop.
- Kate does not have sftp built in, but that is not the whole story.
- Dolphin, the KDE file manager has the ability to do secure FTP, so I can mount a remote folder (on a different computer) and use Kate to open a file from there just as if it were a file on my own computer.
- The separation of sftp into the file manager is in keeping with the Unix/Linux way. Keeping parts separate and reusing them in the mix you want. That "separate tool for separate task" rule often applies mainly to the command line tools used in sequence, but is applied here to two GUI components, the editor and the file manager. The result is super easy editing of remote files.
Step one is to open Dolphin and choose Network from the Places menu and Add new Network Folder.
Step two is to select the SSH Secure Shell connection.
The third step is to fill in the appropriate information for the connection you want to make. (A secure shell server must be running on the RPi for this to work. The SSH server is typically installed by default. I knew the IP address of the RPi by using Nmap which is covered in another RPi note.
I was asked to provide a password to the RPi in a popup window. You didn't think I was going to reveal that password here, did you? (It only shows as dots in the password blank, so you would not have seen it anyway.
I created a short test program using Kate which is running on my laptop, saved it and switched to a secure shell connection to run the test program with the python test.py command line entry. There, before everyone looking over my shoulder, is the result.
From there on, just choose the icon from the list of network connection icons and provide the user password to make a connection to the folder you chose. Just open the file you want in Kate, edit and save. The saved file will be available to use on the RPi.
The Ubuntu Unity Experience
I run Ubuntu in a virtual machine on my laptop when I need it for testing. Ubuntu is the main Linux version supplied by Canonical, though they also support Kubuntu/KDE and other desktop tools to a lesser extent. Ubuntu users will need to take similar steps. Click the Ubuntu button at the top of the Dash and enter sftp://192.168.1.166:22. Using the Ubuntu file manager, you must enter the type of connection, the IP address of the RPi and the port all as a single piece where they were separate GUI steps in Kubuntu. One needs to expect to puzzle out differences when moving from one set of tools to another.
You will see the expected warning about not recognizing the certificate. (I did not see that warning within my own Kubuntu install because I had made a previous secure shell connection via the command line. A virtual computer running inside Kubuntu does not know about the Kubuntu connections, so I saw the certificate warning you should see the first time you make a connection to the RPi.)
Once the connection was there, the file browser displayed my RPi files, and I was able to use the gedit text editor program to modify the test file and then rerun the program via a secure shell command line connection. No matter which tools you use, you will actually need to have two connections to the RPi. One is for the GUI editor. The other is a command line SSH connection to launch programs.