remoter icon indicating copy to clipboard operation
remoter copied to clipboard

Sodium package problem

Open mbahin opened this issue 5 years ago • 6 comments

Hi,

I'm trying to setup remoter to run R from a remote server on my local computer (through Rstudio but I'm not there yet...). I'm still stuck on the step where I'm trying to create a local server and connect from another local session. I have a Ubuntu 18.04 with libsodium package installed:

$dpkg -l | grep libsodium
ii  libsodium-dev:amd64                                   1.0.16-2                                         amd64        Network communication, cryptography and signaturing library - headers
ii  libsodium23:amd64                                     1.0.16-2                                         amd64        Network communication, cryptography and signaturing library
ii  python3-nacl

as well as R sodium lib. When I type "library(sodium)", it works (I don't get if I have to do it before running server and/or client but I did it anyway). But then, when I try to start the server, I get this:

> remoter::server(showmsg=TRUE, secure=TRUE)
Error in remoter::server(showmsg = TRUE, secure = TRUE) : 
  secure servers can only be launched if the 'sodium' package is installed

I can run an unsecure server:

> remoter::server(showmsg=TRUE,)
[2020-08-06 10:10:04]: *** Launching UNSECURE server ***
                           Hostname:     XXX
                           Port:         XXX

But then I'm unable to run stuff on it from the client (I guess it's the reason):

> remoter::client()
remoter> remoter::batch(script="1+1")
Error:  can not spawn client/server/relay or launch a batch connection from inside the client

and if I check sodium, it's false:

remoter> has.sodium()
[1] FALSE 

My "main" R version is a 4 so I had to install a 3.6.3 to be able to install the sodium lib. And I'm running R from there on both sides to make this test. Any idea what I'm doing wrong?

Cheers, Mathieu

mbahin avatar Aug 06 '20 08:08 mbahin

I'm not sure what the issue is with sodium. For the other issue, you should either use client() for interactive use or batch() for batch usage. So when you do client() and the prompt changes to remoter> you're connected to the server. The things you type are sent to the server and evaluated there. You can see this more clearly if you start the server like remoter::server(secure=FALSE, showmsg=TRUE) and watch the server log. Once you have a sever launched, you can do remoter::client() to start typing things interactively, or don't do that and instead do remoter::batch() to pass full scripts.

I've tested sodium+remoter in R 4.0.2, so I don't think you need 3.6.3, although that should work too. Are you using different libraries for the different versions? What happens if you do

library(sodium)
library(remoter)
server(secure=TRUE)

wrathematics avatar Aug 06 '20 12:08 wrathematics

Ok thanks for your reactive answer :), I didn't get this difference between client and interactive before but it makes sense now (and was kind of obvious...).

I was able to run commands remotely the "unsecure" way (from terminal and Rstudio).

So now the last blocking point I have is this sodium problem... The admin installed it on the server and I was able to start a secure server:

> server(showmsg=TRUE, secure=TRUE)
[2020-08-06 16:02:48]: *** Launching secure server ***
                           Hostname:     XXX
                           Port:         YYY

But I still the problem locally...

> library(sodium)
> library(remoter)
Attaching package: ‘remoter’
The following object is masked from ‘package:grDevices’:
    dev.off
The following objects are masked from ‘package:utils’:
    ?, help
> client(addr="XXX", port=YYY, prompt="whatever")
Error in first_send() : 
  remoter server communications are encrypted but the 'sodium' package is not detected on the client.  Please install the 'sodium' package, or start an unsecure server.
> has.sodium()
[1] FALSE

(on the server, has.sodium() returns TRUE as expected)

I don't know where I get this idea that sodium didn't work on R 4.0.2 because I also could install it... Maybe I got confused but what is sure is that on the remote server, the R version is 3.6.3 and I'd like to use this one so I'll stick with 3.6.3.

Cheers, Mathieu

mbahin avatar Aug 06 '20 14:08 mbahin

That's odd. I'm not sure how that's happening.

The test that remoter runs to check for sodium is requireNamespace("sodium", quietly=TRUE) in remoter/R/zzz.r. If you can run library(sodium) from the R session that runs the client, then I don't see how that can fail.

I have no idea if this will work, but you might try downloading the remoter source and setting line 7 of remoter/R/zzz.r to test <- TRUE. Then try this again

library(sodium)
library(remoter)
client(addr="XXX", port=YYY, prompt="whatever")

wrathematics avatar Aug 06 '20 14:08 wrathematics

I re-installed it from sources:

remove.packages("remoter")
install.packages("Downloads/remoter_0.4-0.tar.gz", repos=NULL, type="source")

Now the has.sodium() is TRUE!

> has.sodium()
[1] TRUE

But I have the following error:

> client(addr="XXX", port=YYY)
Error in sodium::auth_decrypt(encrypted, getkey(private), getkey(theirs)) : 
  is.raw(nonce) is not TRUE

I guess we are back to an issue (https://github.com/RBigData/remoter/issues/53) you had previously... :)

Cheers, Mathieu

mbahin avatar Aug 06 '20 15:08 mbahin

Could you try starting the server with the option serialversion=2 and letting me know what happens?

wrathematics avatar Aug 08 '20 12:08 wrathematics

Hi,

I tried the "serialversion=2" but it failed:

> server(showmsg=TRUE, secure=TRUE, serialversion=2)
Error in server(showmsg = TRUE, secure = TRUE, serialversion = 2) : 
  unused argument (serialversion = 2)

However when I tried again this morning, things worked! On the server:

> server(showmsg=TRUE, secure=TRUE)

[2020-08-10 09:37:13]: *** Launching secure server ***
                           Hostname:     XXX
                           Port:         YYY
[2020-08-10 09:38:13]: client connected
[2020-08-10 09:38:13]: RMSG: remoter_env_sync

Locally:

> client(addr="XXX", port=YYY, prompt="Whatever")

Whatever> 

The only thing that happened for me is that I restarted the computer over the weekend but I don't see why it would solve the problem...

Cheers, Mathieu

mbahin avatar Aug 10 '20 07:08 mbahin