This repository was archived by the owner on May 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path10_rdp_windows.sh
51 lines (45 loc) · 1.58 KB
/
10_rdp_windows.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bash
# Starts an IAP TCP forwarding tunnel for RDP
################################################################################
# INCLUDE FUNCTIONS
################################################################################
MY_INCLUDE='../inc/include.sh'
# ignore SC1090
# shellcheck source=/dev/null
if ! source "$MY_INCLUDE"; then
ME=$(basename "$0")
BASE_PATH=$(dirname "$0")
echo;echo "× Can not read required include file '$MY_INCLUDE'";echo
echo " Please start the script directly in the directory:"
echo " cd $BASE_PATH && bash $ME";echo
exit 9
fi
################################################################################
# MAIN
################################################################################
clear
# ASCII art title
tput setaf 4 0 0 # 4 = blue
echo_equals
cat << EOF
_____ _____ _____ _______ _
| __ \| __ \| __ \ |__ __| | |
| |__) | | | | |__) | | |_ _ _ __ _ __ ___| |
| _ /| | | | ___/ | | | | | '_ \| '_ \ / _ \ |
| | \ \| |__| | | | | |_| | | | | | | | __/ |
|_| \_\_____/|_| |_|\__,_|_| |_|_| |_|\___|_|
EOF
echo_equals
tput sgr0 # reset terminal
echo_info "Tunnel local IP '$MY_RDP_LOCAL' port 3389 to '$MY_GCP_GCE_NAME' port 3389 for RDP"
echo
echo
echo "Connect to '$MY_GCP_GCE_NAME' via RDP:"
echo "> mstsc /v:$MY_RDP_LOCAL:3389"
echo
echo_info "Exit with [Ctrl] + [C]"
echo
gcloud compute start-iap-tunnel "$MY_GCP_GCE_NAME" 3389 \
--local-host-port="$MY_RDP_LOCAL:3389" \
--zone="$MY_GCP_ZONE" \
--project="$MY_GCP_PROJECT"