mirror of
https://github.com/DictXiong/dotfiles.git
synced 2025-07-01 21:00:29 +08:00
feat(riot): sshd can specify the local port
This commit is contained in:
parent
3bdc43421d
commit
4e99cc1580
24
scripts/riot
24
scripts/riot
@ -190,12 +190,12 @@ run_sshl()
|
|||||||
# sshd
|
# sshd
|
||||||
run_sshd()
|
run_sshd()
|
||||||
{
|
{
|
||||||
local port=$(get_free_port)
|
local port=${1:-$(get_free_port)}
|
||||||
SSH_OPTIONS+=("-NC" "-D" "$port")
|
SSH_OPTIONS+=("-NC" "-D" "$port")
|
||||||
prepare_ssh_cmd ssh
|
prepare_ssh_cmd ssh
|
||||||
fmt_note "-->" "${CMD[@]}"
|
fmt_note "-->" "${CMD[@]}"
|
||||||
fmt_note " > please access localhost:$port"
|
fmt_note " > please access localhost:$port"
|
||||||
eval_or_echo $cmd
|
eval_or_echo
|
||||||
}
|
}
|
||||||
|
|
||||||
# scp
|
# scp
|
||||||
@ -251,12 +251,13 @@ print_help()
|
|||||||
fmt_info "usage: $0 [-Ddhlqt] [--dry-run] [--dev] [--help] [--lite] [--quite] [--trust] [--tmux] [--password] [[-o ssh-option]...] remote [command] [--] [ssh-command-args]"
|
fmt_info "usage: $0 [-Ddhlqt] [--dry-run] [--dev] [--help] [--lite] [--quite] [--trust] [--tmux] [--password] [[-o ssh-option]...] remote [command] [--] [ssh-command-args]"
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
available commands:
|
available commands:
|
||||||
- ssh (default)
|
- ssh [ssh-command-args] (default)
|
||||||
- tmux (run ssh in multiple tmux windows)
|
- tmux [ssh-command-args] (run ssh in multiple tmux windows)
|
||||||
- sshl (ssh -L)
|
- sshl [local-port:remote-host:]remote-port (ssh -L)
|
||||||
- sshd (ssh -D)
|
- sshd [local-port] (ssh -D)
|
||||||
- zssh
|
- zssh [ssh-command-args]
|
||||||
- sftp
|
- sftp
|
||||||
|
- scp source destination
|
||||||
- rm (remove host keys)
|
- rm (remove host keys)
|
||||||
- ping/ping4/ping6 (ping the remote servers)
|
- ping/ping4/ping6 (ping the remote servers)
|
||||||
EOF
|
EOF
|
||||||
@ -336,8 +337,13 @@ router() {
|
|||||||
run_sshl "${positional[2]}"
|
run_sshl "${positional[2]}"
|
||||||
;;
|
;;
|
||||||
sshd )
|
sshd )
|
||||||
test "${#positional[@]}" -eq 2 || fmt_fatal "sshd requires no arguments"
|
test "${#positional[@]}" -le 3 || fmt_fatal "sshd requires one or no arguments"
|
||||||
run_sshd # TODO: support port number
|
if [[ "${#positional[@]}" -eq 3 ]]; then
|
||||||
|
check_port "${positional[2]}" || fmt_fatal "invalid port number: ${positional[2]}"
|
||||||
|
run_sshd "${positional[2]}"
|
||||||
|
else
|
||||||
|
run_sshd
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
scp )
|
scp )
|
||||||
test "${#positional[@]}" -eq 4 || fmt_fatal "scp requires exactly two arguments: source and destination"
|
test "${#positional[@]}" -eq 4 || fmt_fatal "scp requires exactly two arguments: source and destination"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user