Created
October 3, 2021 17:20
-
-
Save igaskin/ee2fcbd9033f99f77f4ff44ccd040d64 to your computer and use it in GitHub Desktop.
shell script for updating IP in ssh config for Google Cloud Shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
update_cloud_shell_ip () { | |
IP=$(gcloud alpha cloud-shell ssh --dry-run | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}') | |
OLDIP=`grep -w cloud-shell -A 1 $HOME/.ssh/config | awk '/HostName/ {print $2}'` | |
sed -i "" "s/$OLDIP/$IP/g" $HOME/.ssh/config | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment