# Basic remote procedure call via ssh from Linux to Windows

**URL:** https://discourse.julialang.org/t/basic-remote-procedure-call-via-ssh-from-linux-to-windows/18743
**Category:** Julia at Scale
**Created:** [December 17, 2018, 1:49pm UTC](https://discourse.julialang.org/t/basic-remote-procedure-call-via-ssh-from-linux-to-windows/18743 "2018-12-17T13:49:32Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![mgkuhn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mgkuhn/32/6276_2.png) [@mgkuhn](https://discourse.julialang.org/u/mgkuhn)
#### Post date: [December 17, 2018, 1:49pm UTC](https://discourse.julialang.org/t/basic-remote-procedure-call-via-ssh-from-linux-to-windows/18743/1 "2018-12-17T13:49:32Z")

</div>

I have a Julia application running under Linux. I would like to make a couple of remote function calls to another Julia process running on a specific Windows machine, because that Windows machine has special data-acquisition hardware for which only a Win32 driver is available.

I have Julia installed on both the Linux and Windows machine, and I have Microsoft’s OpenSSH port set up such that I can perform password-free ssh logins from Linux to Windows. However, the Linux and Windows machines have of course very different file paths.

The [Julia documentation on distributed computing](https://docs.julialang.org/en/v1/manual/parallel-computing/#Starting-and-managing-worker-processes-1) focuses at the moment very much on clusters of worker machines that share the same file-path name space, and where the user may not care much on which exact worker machine a job ends up.

Where do I start if, rather than creating a homogeneous compute cluster, I just want to call Julia functions on one particular machine (to control some hardware there) where Julia and my code are installed on very different file paths (because its a rather different operating system)?

Is there somewhere a lower layer API than the ClusterManager that I can use to open just one ssh channel from a Linux machine to a Windows machine to call there a couple of Julia functions?

---

<div class="post-metadata">

### Author: ![ksmcreynolds](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ksmcreynolds/32/860_2.png) [@ksmcreynolds](https://discourse.julialang.org/u/ksmcreynolds)
#### Post date: [December 18, 2018, 4:54pm UTC](https://discourse.julialang.org/t/basic-remote-procedure-call-via-ssh-from-linux-to-windows/18743/2 "2018-12-18T16:54:16Z")

</div>

While I haven’t done this before, I would start with [`addprocs`](https://docs.julialang.org/en/v1/stdlib/Distributed/#Distributed.addprocs) (the second method which takes a vector of `machine_spec` strings as the first argument). You can specify the path to the `julia` executable on the remote worker using the `exename` keyword argument and the working directory with the `dir` keyword argument.

---

<div class="post-metadata">

### Author: ![mgkuhn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mgkuhn/32/6276_2.png) [@mgkuhn](https://discourse.julialang.org/u/mgkuhn)
#### Post date: [January 6, 2019, 1:06am UTC](https://discourse.julialang.org/t/basic-remote-procedure-call-via-ssh-from-linux-to-windows/18743/3 "2019-01-06T01:06:17Z")

</div>

It turned out that the SSHManager in the Distributed package so far only supported ssh servers that invoke a POSIX shell (e.g., bash). I have now added to addprocs() a new keyword argument `shell=:wincmd` that causes SSHManager to prepage a remote command line for invoking `julia --worker` via `cmd.exe`. This is the [default shell](https://github.com/PowerShell/Win32-OpenSSH/wiki/DefaultShell) that sshd invokes in [Microsoft’s OpenSSH port for Windows](https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse). See [pull request #30614](https://github.com/JuliaLang/julia/pull/30614).

---

<div class="post-metadata">

### Author: ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)
#### Post date: [January 13, 2019, 10:24am UTC](https://discourse.julialang.org/t/basic-remote-procedure-call-via-ssh-from-linux-to-windows/18743/4 "2019-01-13T10:24:52Z")

</div>

@mgkuhn I would look at the excellent MobXterm [https://mobaxterm.mobatek.net/](https://mobaxterm.mobatek.net/)  
It includes an ssh server and maybe it could help with the path issues also.

---

<div class="post-metadata">

### Author: ![anj](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@anj](https://discourse.julialang.org/u/anj)
#### Post date: [September 23, 2019, 6:28am UTC](https://discourse.julialang.org/t/basic-remote-procedure-call-via-ssh-from-linux-to-windows/18743/5 "2019-09-23T06:28:49Z")

</div>

> [@mgkuhn](#):
>
> shell=:wincmd

I understand this is not working (julia 1.2.0). Any idea how to make windows/windows communication? I made windows-\>windows communication using OpenSSH using keys. that part works. but then julia fails to add processes on the remote.

I guess another way is to make OpenSSH server to use some other shell, which would be posix compatible?

---

<div class="post-metadata">

### Author: ![mgkuhn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mgkuhn/32/6276_2.png) [@mgkuhn](https://discourse.julialang.org/u/mgkuhn)
#### Post date: [September 23, 2019, 10:51am UTC](https://discourse.julialang.org/t/basic-remote-procedure-call-via-ssh-from-linux-to-windows/18743/6 "2019-09-23T10:51:26Z")

</div>

My [pull request #30614](https://github.com/JuliaLang/julia/pull/30614) has not yet been merged into masters. I have still to do the slight refactoring requested by vtjnash, i.e. move the `cmd.exe` escaping algorithm into `base/shells.jl` (and also provide an equivalent for PowerShell and add some tests). I just got side-tracked by other projects, finishing this patch is still on my todo list. I also plan to add a separate option for whether to pass the cluster\_cookie via stdin or via the command line, because whether communication via stdin/stdout works or not really depends on the exact Windows/OpenSSH/Julia version used: older versions required OpenSSH to do some horrid `cmd.exe` screen scraping that made stdin/stdout communication impractical, whereas with ConPTY support added in more recent versions this may have become better now.

---

<div class="post-metadata">

### Author: ![mgkuhn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mgkuhn/32/6276_2.png) [@mgkuhn](https://discourse.julialang.org/u/mgkuhn)
#### Post date: [November 25, 2020, 6:04pm UTC](https://discourse.julialang.org/t/basic-remote-procedure-call-via-ssh-from-linux-to-windows/18743/7 "2020-11-25T18:04:34Z")

</div>

Support for the new `Distributed.addprocs` parameter `shell=:wincmd`, to specify that the shell that answers the ssh connection is Windows’ `cmd.exe`, was recently merged into the `master` branch (i.e., should now be working on Julia nightly 1.6.0-DEV).

Example:

```julia
using Distributed
exename = raw"C:\Program Files\Julia-latest\bin\julia";
pids = addprocs(["windows-host1.dept.cam.ac.uk"];
                shell=:wincmd, dir=nothing, exename)
remote = pids[1];
@show remotecall_fetch(Sys.windows_version, remote)
@show remotecall_fetch(pwd, remote)

```

---

<div class="post-metadata">

### Author: ![dburch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dburch/32/8741_2.png) [@dburch](https://discourse.julialang.org/u/dburch)
#### Post date: [December 28, 2020, 10:17pm UTC](https://discourse.julialang.org/t/basic-remote-procedure-call-via-ssh-from-linux-to-windows/18743/8 "2020-12-28T22:17:59Z")

</div>

Thanks for posting this. I just spent an entire day trying to figure at why I was getting “‘sh’ is not recognized as an internal or external command.” The only problem is that I’m using the long term stable version 1.0.5. Would this fix every make it into 1.0.5 somehow or would I have to upgrade to 1.6 when it is released?

---

<div class="post-metadata">

### Author: ![mgkuhn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mgkuhn/32/6276_2.png) [@mgkuhn](https://discourse.julialang.org/u/mgkuhn)
#### Post date: [December 29, 2020, 12:52pm UTC](https://discourse.julialang.org/t/basic-remote-procedure-call-via-ssh-from-linux-to-windows/18743/9 "2020-12-29T12:52:48Z")

</div>

“[Real Men](https://www.ee.ryerson.ca/~elf/hack/realmen.html)” use [nightlies](https://julialang.org/downloads/nightlies/) … 😉

The `shell` keyword argument to `addprocs()` is new functionality, rather than a bug fix, so I doubt anyone will backport it to 1.0._x_.

So for now, I’d suggest you install [nightlies](https://julialang.org/downloads/nightlies/) to try it out. (You can have several Julia versions installed at the same time.) The calling party needs to be Julia 1.6 or newer.

If the worker runs an older version of Windows (probably pre-1809) or Julia (I think pre-1.3 or so, not sure) or [OpenSSH for Windows](https://github.com/PowerShell/Win32-OpenSSH/releases) (probably pre-[v7.9](https://github.com/PowerShell/Win32-OpenSSH/releases/tag/v7.9.0.0p1-Beta)), you may also have to add the keyword argument `cmdline_cookie=true` as a workaround if your connection-attempt hangs. (This is, because of the horrid way in which with older, pre-[ConPTY](https://devblogs.microsoft.com/commandline/windows-command-line-introducing-the-windows-pseudo-console-conpty/) versions, OpenSSH for Windows has to capture the output of the Julia worker via screen scraping text from an off-screen console window, and it therefore won’t see some control characters correctly, such as a trailing newline of the output of the Julia worker, which signals that it is time for the caller to send the cookie. Until very recently, Windows _really_ wasn’t meant to be ssh-ed into.)

See also the [Distributed.addprocs 1.7-DEV documentation](https://docs.julialang.org/en/v1.7-dev/stdlib/Distributed/#Distributed.addprocs).
