Skip to content

Instantly share code, notes, and snippets.

@timwb
Last active September 11, 2021 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save timwb/1f95737d54563aedd7c97d5e671667cc to your computer and use it in GitHub Desktop.
Save timwb/1f95737d54563aedd7c97d5e671667cc to your computer and use it in GitHub Desktop.
.ssh/config line to connect to a Leaseweb server by ServerId
# Usage: ssh root@2103823.lsw
# Don't forget to put your API key (or a variable) in the ProxyCommand line.
Host *.lsw
# Uncomment these only if you absolutely trust your servers, and they change host keys often, for example when you use rescue mode a lot.
#StrictHostKeyChecking no
#UserKnownHostsFile /dev/null
#User root
ProxyCommand nc $(curl -s -X GET --url https://api.leaseweb.com/bareMetals/v2/servers/$(cut -d'.' -f1 <<< %h)/ips -H "x-lsw-auth: YOUR-LEASEWEB-API-KEY-HERE" | jq --raw-output '.ips[] | select(.mainIp==true) | .ip' | cut -d'/' -f1) %p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment