Skip to content

Instantly share code, notes, and snippets.

@muhummadPatel
Created September 26, 2016 14:37
Show Gist options
  • Select an option

  • Save muhummadPatel/4d4afc442b18cdc4e064ce06a8c2b201 to your computer and use it in GitHub Desktop.

Select an option

Save muhummadPatel/4d4afc442b18cdc4e064ce06a8c2b201 to your computer and use it in GitHub Desktop.
Python script to upload current computers public IP address to a github gist.
# Finds your public ip and writes it to a github gist. Run this as a cronjob as often as you like
# When you need to ssh in, just check the gist for the ip to use
# requires simplegist: pip install simplegist
from datetime import datetime
from simplegist import Simplegist
from urllib2 import urlopen
gg = Simplegist(username='[github username]', api_token='[github api token]')
current_time = str(datetime.now())
ip = urlopen('http://ipinfo.io/ip').read().strip()
content = current_time + " " + ip
gg.profile().edit(id='[gist id]', content=content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment