Add suport DNS srv record type to ssh client (https://www.ietf.org/rfc/rfc2782.txt)
#!/bin/bash | |
target_host=$1 | |
if [ ! -z "$2" ];then | |
target_port=$2 | |
else | |
target_port="22" | |
fi | |
while read record;do | |
if [ ! -z "$record" ];then | |
host=$(echo $record | awk '{print $NF}') | |
port=$(echo $record | awk '{print $(NF-1)}') | |
if timeout 1 bash -c "cat < /dev/null > /dev/tcp/$host/$port" &> /dev/null;then | |
target_host=$host | |
target_port=$port | |
break | |
fi | |
fi | |
done < <(dig +short SRV _ssh._tcp.$target_host @$(dig +short NS $(echo $target_host | awk -F '.' '{print $(NF-1)"."$NF}') | head -n1) | sort -nk1) | |
socat STDIO TCP:$target_host:$target_port 2> /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
just add -o ProxyCommand=sshsrv-proxy-command.sh %h %p on ssh command
or edit ~/.ssh/config file and put:
Host *.DOMAIN
ProxyCommand=sshsrv-proxy-command.sh %h %p