Provide a login port for user, determine whether to send the ssh_port message based on the uuid.
Signed-off-by: Zhang Yale zhangyale3@huawei.com --- lib/forward_port.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 lib/forward_port.sh
diff --git a/lib/forward_port.sh b/lib/forward_port.sh new file mode 100755 index 00000000..a2264e62 --- /dev/null +++ b/lib/forward_port.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# uuid + +. $LKP_SRC/lib/http.sh + +sshr_ip=$LKP_SERVER +sshr_port=5050 +[ -n "$sshr_port_len" ] || sshr_port_len=2000 +[ -n "$sshr_port_base" ] || sshr_port_base=50000 + +get_port() +{ + [ -n "$uuid" ] || return + for i in $(seq 1 10) + do + port=$(($(date +%s%N)%"$sshr_port_len"+"$sshr_port_base")) + ssh -o StrictHostKeyChecking=no \ + -o ExitOnForwardFailure=yes -o TCPKeepAlive=yes -Nf -R $port:localhost:22 sshr@"$sshr_ip" -p "$sshr_port" &>/dev/null + [ $? -eq 0 ] || continue + echo "$port" + break + done +}
I'm sorry, pls ignore this, thanks.
On Wed, Oct 14, 2020 at 08:49:40PM +0800, Zhang Yale wrote:
Provide a login port for user, determine whether to send the ssh_port message based on the uuid.
Signed-off-by: Zhang Yale zhangyale3@huawei.com
lib/forward_port.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 lib/forward_port.sh
diff --git a/lib/forward_port.sh b/lib/forward_port.sh new file mode 100755 index 00000000..a2264e62 --- /dev/null +++ b/lib/forward_port.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# uuid
+. $LKP_SRC/lib/http.sh
+sshr_ip=$LKP_SERVER +sshr_port=5050 +[ -n "$sshr_port_len" ] || sshr_port_len=2000 +[ -n "$sshr_port_base" ] || sshr_port_base=50000
+get_port() +{
- [ -n "$uuid" ] || return
- for i in $(seq 1 10)
- do
port=$(($(date +%s%N)%"$sshr_port_len"+"$sshr_port_base"))
ssh -o StrictHostKeyChecking=no \
-o ExitOnForwardFailure=yes -o TCPKeepAlive=yes -Nf -R $port:localhost:22 sshr@"$sshr_ip" -p "$sshr_port" &>/dev/null
[ $? -eq 0 ] || continue
echo "$port"
break
- done
+}
2.23.0