Skip to content

Instantly share code, notes, and snippets.

@krab7191
Created September 30, 2023 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krab7191/42b13a6f9c0ee9aad0f798ddbacd70f3 to your computer and use it in GitHub Desktop.
Save krab7191/42b13a6f9c0ee9aad0f798ddbacd70f3 to your computer and use it in GitHub Desktop.
Shell script to SSH to raspberry pi wherever I am
#!/bin/bash
network=$(iwgetid -r)
echo "Connected to network: "
echo $network
if [ "$network" = "<Your home wifi SSID>" ]; then
echo "At home, SSH to pi on local network"
ssh username@pi-local-ip
else
echo "Not at home, SSH to pi at home public IP"
ssh username@home-public-ip-address
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment