Skip to content

Instantly share code, notes, and snippets.

@emre
Last active December 14, 2015 04:29
Show Gist options
  • Save emre/5028699 to your computer and use it in GitHub Desktop.
Save emre/5028699 to your computer and use it in GitHub Desktop.
cok fazla sunucu uzerinde calisinca cok fazla alias yazmak zorunda kalabiliyorsunuz ssh baglantilari icin. ssh auth konusunu password olmadan hallediyorsaniz goto makine1, goto solr_server, goto X seklinde ip adresleriyle ugrasmadan baglanti yapmanizi kolaylastiran ufak bir script.
#!/usr/bin/python
import os
import sys
try:
import simplejson as json
except ImportError:
import json
# {
# "netscaler": {"ip": "xx.xx.xx.xx", "user": "nsroot"},
# "vps": {"ip": "xx.xx.xx.xx", "user": "root"}
# }
config_file = "/usr/share/goto-servers.json"
configuration = json.loads(open(config_file).read())
if len(sys.argv) > 1:
server = sys.argv[1]
else:
print 'why are you doing that?'
sys.exit(0)
server_entry = configuration.get(server, None)
if not server_entry:
print 'no entry found.'
sys.exit(0)
os.system("ssh %s@%s" % (server_entry.get("user"), server_entry.get("ip")))
@emre
Copy link
Author

emre commented Mar 4, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment