Skip to content

Commit b8d4a39

Browse files
committed
allow customization of ssh fwd port (fixes mschubert#296)
1 parent dad2f5d commit b8d4a39

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

R/qsys_ssh.r

+5-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ SSH = R6::R6Class("SSH",
2323
# set forward and run ssh.r (send port, master)
2424
opts = private$fill_options(ssh_log=ssh_log, ssh_host=ssh_host)
2525
ssh_cmd = fill_template(private$template, opts,
26-
required=c("local_port", "remote_port", "ssh_host"))
26+
required=c("local_port", "ssh.hpc_fwd_port", "ssh_host"))
2727

2828
# wait for ssh to connect
2929
message(sprintf("Connecting to %s via SSH ...", sQuote(ssh_host)))
@@ -52,11 +52,10 @@ SSH = R6::R6Class("SSH",
5252
ssh_proxy_running = TRUE,
5353

5454
fill_options = function(...) {
55-
values = utils::modifyList(private$defaults, list(...))
56-
#TODO: let user define ports in private$defaults here and respect them
57-
values$local_port = sub(".*:", "", private$addr)
58-
values$remote_port = sample(50000:55000, 1)
59-
values
55+
args = list(...)
56+
args$local_port = sub(".*:", "", private$addr)
57+
args$ssh.hpc_fwd_port = getOption("clustermq.ssh.hpc_fwd_port", sample(50000:55000, 1))
58+
utils::modifyList(private$defaults, args)
6059
},
6160

6261
finalize = function(quiet = self$workers_running == 0) {

inst/SSH.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ssh -o "ExitOnForwardFailure yes" -f
2-
-R {{ remote_port }}:127.0.0.1:{{ local_port }}
2+
-R {{ ssh.hpc_fwd_port }}:127.0.0.1:{{ local_port }}
33
{{ ssh_host }}
44
"R --no-save --no-restore -e
5-
'clustermq:::ssh_proxy({{ remote_port }})'
5+
'clustermq:::ssh_proxy({{ ssh.hpc_fwd_port }})'
66
> {{ ssh_log | /dev/null }} 2>&1"

vignettes/userguide.Rmd

+3
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,9 @@ time after you restart R.
293293
(e.g. `"~/cmq_ssh.log"`); helpful for debugging purposes
294294
* `clustermq.ssh.timeout` - The amount of time to wait (in seconds) for a SSH
295295
start-up connection before timing out (default is `10` seconds)
296+
* `clustermq.ssh.hpc_fwd_port` - Port that will be opened for SSH reverse
297+
tunneling between the workers on the HPC and a local session
298+
(default: one integer in the range of 50-55k)
296299
* `clustermq.worker.timeout` - The amount of time to wait (in seconds) for
297300
master-worker communication before timing out (default is to wait
298301
indefinitely)

0 commit comments

Comments
 (0)