Skip to content

Instantly share code, notes, and snippets.

@gadelkareem
Created January 8, 2020 19:37
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 gadelkareem/fd9c1803d2d43fb35b132f547c2ef8fe to your computer and use it in GitHub Desktop.
Save gadelkareem/fd9c1803d2d43fb35b132f547c2ef8fe to your computer and use it in GitHub Desktop.
Login hetzner by VM name
#!/usr/bin/env bash
set -eo pipefail
READ_LINK=$([[ "$OSTYPE" == "darwin"* ]] && echo greadlink || echo readlink)
cd "$(dirname $(${READ_LINK} -f "${BASH_SOURCE[0]}"))/.."
IP=$(hcloud server list --selector "name=$1" --output noheader --output columns=IPV4)
echo Connecting to $1 IP: $IP
ssh -o CheckHostIP=no -o TCPKeepAlive=yes -o StrictHostKeyChecking=no -o ServerAliveInterval=120 -o ServerAliveCountMax=100 root@${IP}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment