Last active
December 14, 2015 04:29
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://mattryall.net/blog/2008/06/ssh-favourite-hosts
DEPREKEYTID