I have a private R package repository on a server accessible by ssh. When running R on the server I can install packages from the repo with install.packages
by setting a the following option
options(repos=c("http://ftp.sunet.se/pub/lang/CRAN",
"file:///path/to/repo/base/directory"))
install.packages("myPrivateGoodies")
Is it possible to do the same from an R session on my local machine by setting an url over ssh? I imagine that it should be easy to set up but I can't get any of the following to work:
options(repos=c("http://ftp.sunet.se/pub/lang/CRAN",
"ssh://user@server:/path/to/repo/base/directory",
"sftp://user@server:/path/to/repo/base/directory"))
The manual says nothing about ssh but states that https generally do not work, so maybe ssh is also problematic. RSA authentification is taken care of in ~/.ssh/config
and I can connect to the repo from the terminal without problems with sftp user@server:/path/to/repo/base/directory
(without having to enter any password).
Following the advice of @spacedman and using this guide I managed to make it work seemlessly just like I wanted it to.
In bash
$ sshfs server:/path/to/repo/base/directory ~/mnt/remote-repo
Then in R
options(repos=c("http://ftp.sunet.se/pub/lang/CRAN",
"file:///home/backlin/mnt/remote-repo"))
That won't work.
What will work is if you can set up an ssh network file system on your server. Basically this looks like a normal file path, is accessible via a file:// URL in the repos options, but the operating system maps all access under that folder to a remote server, transparently to the user, using the SSH protocol.
You need an sshfs file system driver on your server, and the client tools and permissions to mount them, which is beyond the scope of this forum.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With