SSH Port Forwarding
Whenever I need to access a server running on an HPC which does not support ngrok
or localtunnel
or even gsocket
; the fallback approach is always to rely on SSH port forwarding.
The sample problem here is running an HTTP server for viewing graphics in R via httpgd
.
1# Local
2export PORT=9899 && ssh -L "${PORT}:localhost:${PORT}" "rog32@krafla.rhi.hi.is" -N -L "${PORT}:localhost:${PORT}" elja
3# New tab
4ssh krafla
5ssh elja
6radian # or R
Now in R
.
1library("httpgd")
2# else install.packages(c("httpgd"), repos='https://cran.hafro.is/')
3hgd(port=9899)
Conda and R
Annoyingly if you are depending on conda
or micromamba
or some variant thereof on the remote sever then install.packages
will fail and instead the environment needs to have the corresponding R
packages installed after searching anaconda.org.
1# minimal
2micromamba create -p $(pwd)/.tmp -c conda-forge r-tidyverse git R
3micromamba activate $(pwd)/.tmp
4micromamba install -c nclibz r-httpgd
These issues are not present when using a nix-shell
.
Comments