Provide a login port for user, determine whether to send the ssh_port message based on the uuid.
Signed-off-by: Zhang Yale ylzhangah@qq.com Signed-off-by: Zhang Yale ylzhangah@qq.com --- lib/transfer_port.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 lib/transfer_port.sh
diff --git a/lib/transfer_port.sh b/lib/transfer_port.sh new file mode 100755 index 00000000..61fb67b4 --- /dev/null +++ b/lib/transfer_port.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# uuid + +. $LKP_SRC/lib/http.sh + +sshr_ip=$LKP_SERVER +sshr_port=5050 + +get_port() +{ + [ -n "$uuid" ] || return + for i in $(seq 1 10) + do + port=$(($(date +%s%N)%10+11333)) + 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 +} +