New Plugin: SSH Interface - v0.0.1 ALPHA

I've been working on this plugin off and on for a bit now and after a few rewrites I'm finally at a point where I'm comfortable enough with the framework that I want to release an alpha build to those that might want to try it out and help improve it. This is flagged for py3 compat but don't expect it to work yet.. Expect issues.

I mainly wrote this for the terminal so everything else is just extra.

OctoPrint 1.4.0+ required.

This won't be going into the plugin repo for a while for obvious reasons.


Nice. I had done this with one my pis in the past, and just redirect a url path via haproxy to another port on the back end. You should include a very clear warning that you do not want to put this type of connection insecurely on the internet in any way.

Edit: and yeah, I wasn't paying attention and loaded in Python3 dev environment and sure enough, there were byte/str

Didn't think to ask, is this linux only by chance or you have to have a local ssh server running for it to connect to, because getting a weird error on startup in my Python 2 dev environment.

2020-04-28 20:58:35,270 - octoprint.plugin.core - INFO - Initialized 24 plugin implementation(s)
Exception in thread Thread-16:
Traceback (most recent call last):
  File "c:\python27\Lib\", line 801, in __bootstrap_inner
  File "c:\python27\Lib\", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "c:\octoprint\venv\lib\site-packages\octoprint_sshinterface\", line 106, in _run_ssh
    pubKey, privKey = self._load_ssh_keypair()
  File "c:\octoprint\venv\lib\site-packages\octoprint_sshinterface\", line 66, in _load_ssh_keypair
    privateKey = keys.Key.fromString(data=privateBlob)
  File "c:\octoprint\venv\lib\site-packages\twisted\conch\ssh\", line 172, in fromString
    raise BadKeyError('cannot guess the type of %r' % (data,))
BadKeyError: cannot guess the type of ''

@jneilliii It's written in python and as such embedded into the plugin. No "real" SSH server required. Should be able to work on all operating systems.

90% sure the error is due to my lazy handling of the data directory. Take a look at what self.private_key_file = self._plugin_data_dir + '/id_rsa' resolves to.

Might have been related to my failed Python3 startup, my two dev virtualenv's share the same config path. After deleting/clearing the data and restarting OctoPrint it seems to load up fine without issues. I was able to SSH to the custom port 2222 and run commands.

How does this work with User Access (or does it)?

@OutsourcedGuru it requires Access Control to be enabled with valid users. Auth is run against the OctoPrint user DB. Permissions for actions are checked within the shell (Though I'm sure I missed something).

1 Like