Skip to content

Instantly share code, notes, and snippets.

@134130
Created July 3, 2024 17:51
Show Gist options
  • Save 134130/0cfcd22cb02255a6cb7ac8feb9e3b867 to your computer and use it in GitHub Desktop.
Save 134130/0cfcd22cb02255a6cb7ac8feb9e3b867 to your computer and use it in GitHub Desktop.
run-kubectl-via-ssh-tunnel.sh
export LOCAL_PORT=1080
export [email protected]
# ssh를 통해 SOCKS5 Proxy를 백그라운드에 실행
ssh -fNq -D "$LOCAL_PORT" "$TARGET"
# SOCKS Proxy 정보를 로컬에 구성
export HTTPS_PROXY="socks5://localhost:$LOCAL_PORT"
# SOCKS Proxy 구성정보와 함께 kubectl 명령어 실행
kubectl get pods
kubectl get ns
# 사용완료시, SOCKS5 Proxy 중지
ps aux | grep "ssh -fNq -D $LOCAL_PORT" | grep -v grep | awk '${print $2}' | xargs kill
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment