12
$\begingroup$

It looks like the new RemoteConnect and RemoteRunProcess functions have the potential to dramatically simplify one of my workflows.

However, I will probably need to SSH to machines that have non-default SSH ports( the default port is 22) open.

Is there any way to change this, maybe on the SSH side? Nothing obvious jumps out at me from the documentation.

$\endgroup$
4
  • 1
    $\begingroup$ This works for mail servers running on non-standard ports MailServerConnect["host.example.com", Authentication -> <|"PortNumber" -> NNN|>]. Try that with RemoteConnect. $\endgroup$ Commented Oct 19, 2018 at 22:17
  • 1
    $\begingroup$ Sadly that does not appear to work. Looking at the def for RemoteConnect (it's not ReadProtected or anything) there really isn't a way to do it. $\endgroup$
    – Pillsy
    Commented Oct 22, 2018 at 16:26
  • $\begingroup$ You may want to do the port tunneling. However, this is not a MA solution. $\endgroup$
    – yarchik
    Commented Dec 22, 2019 at 13:35
  • $\begingroup$ Do you have a solution now?I'm struggling with that, too $\endgroup$
    – yode
    Commented Mar 15 at 10:10

1 Answer 1

2
$\begingroup$

With the current implementation of RemoteConnect, it seems that this is unfortunately not possible. Port 22 is hardcoded in the Wolfram Library that is used for SSH connections.

Apart from an elegant and simple solution with port tunneling, mentioned by @yarchik in the comments, you can also use a somehow more clumsy workaround with using an external library. I've used a python library paramiko in the code below.

session = StartExternalSession["Python"]

ExternalEvaluate[session, "
   import paramiko

   client = paramiko.SSHClient()
   client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
   client.connect('localhost', port=5000, username='domen', password='***')

   _stdin, _stdout,_stderr = client.exec_command(\"whoami\")
   _stdout.read().decode()"]
(* laptop\domen *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.