riot: dynamic port forwarding

This commit is contained in:
xiongdian.me 2023-12-07 18:24:56 +08:00
parent ce657c8300
commit 35c302a445

View File

@ -163,6 +163,18 @@ run_sshl()
eval_or_echo $cmd eval_or_echo $cmd
} }
# sshd
run_sshd()
{
local port=$(get_free_port)
SSH_OPTIONS="$SSH_OPTIONS -NC -D $port"
local cmd="$(prepare_ssh_cmd ssh)"
fmt_note "-->" $cmd
fmt_note " > please access localhost:$port"
eval_or_echo $cmd
}
# scp # scp
run_scp() { run_scp() {
local src="$1" local src="$1"
@ -228,6 +240,9 @@ router() {
test -n "$3" || fmt_fatal "no target address provided" test -n "$3" || fmt_fatal "no target address provided"
run_sshl "$3" run_sshl "$3"
;; ;;
sshd )
run_sshd
;;
scp ) scp )
test -n "$3" || fmt_fatal "no source path specified" test -n "$3" || fmt_fatal "no source path specified"
test -n "$4" || fmt_fatal "no destination path specified" test -n "$4" || fmt_fatal "no destination path specified"