Add sshproxy()
This commit is contained in:
parent
0506b66d91
commit
ce31dbea7f
9
.config/zsh/completions/_sshproxy
Normal file
9
.config/zsh/completions/_sshproxy
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#compdef sshproxy
|
||||||
|
|
||||||
|
_arguments '-h[short help text]' \
|
||||||
|
'--port[local port]:port:' \
|
||||||
|
'1:server:_ssh_hosts'
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: shell-script
|
||||||
|
# End:
|
23
.config/zsh/functions/sshproxy
Executable file
23
.config/zsh/functions/sshproxy
Executable file
|
@ -0,0 +1,23 @@
|
||||||
|
#!/usr/bin/env zsh
|
||||||
|
# Opens SOCKS5 proxy over SSH
|
||||||
|
|
||||||
|
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
|
||||||
|
|
||||||
|
zmodload zsh/zutil
|
||||||
|
local -a o_help=()
|
||||||
|
local -a o_port=()
|
||||||
|
zparseopts -D -K -- h=o_help -port:=o_port
|
||||||
|
if [[ ${#o_help} -ne 0 || ! -v 1 ]]; then
|
||||||
|
local ret=$(( ${#o_help} ^ 1 ))
|
||||||
|
print -u $(( 1 + ${ret} )) "usage: ${0} [-h] <HOST>"
|
||||||
|
return ${ret}
|
||||||
|
fi
|
||||||
|
local host=${1}
|
||||||
|
local port="1080"
|
||||||
|
[[ ${#o_port} -eq 2 ]] && port=${o_port[2]}
|
||||||
|
|
||||||
|
print -P "%F{12}starting SOCKS5 proxy over SSH tunnel to" \
|
||||||
|
"%F{magenta}${host}%f %F{12}on %F{13}[::1]:${port}%f %F{12}…"
|
||||||
|
print -P "%F{12}curl environment variable:" \
|
||||||
|
"%F{13}ALL_PROXY='socks5://[::1]:${port}'%f"
|
||||||
|
ssh -D "[::1]:${port}" -N -T ${host}
|
Loading…
Reference in New Issue
Block a user