-
-
Save santalex/4ec942b2fa871a6fa767d8e43c892074 to your computer and use it in GitHub Desktop.
mycli ssh tunnel 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 | |
sshtunnel = None | |
with open('mysql/'+sys.argv[1]) as f: | |
s = f.read() | |
if len(s) > 0 and s[0] == '#': | |
sshtunnel = s[1:].split('\n')[0] | |
if sshtunnel and os.system('ssh -O check %s-controlmaster' % sshtunnel) != 0: | |
os.system('ssh -f %s-controlmaster sleep 60' % sshtunnel) | |
os.execvp('mycli', ['mycli', '--defaults-file', '/home/meeuw/mysql/'+sys.argv[1], '--prompt', sys.argv[1]+' \d > ']+sys.argv[2:]) |
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
Host remotehost-controlmaster | |
ControlMaster auto | |
ControlPath /home/meeuw/.ssh/remotehost-socket | |
HostName remotehost | |
User user | |
LocalForward 3306 localhost:3306 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment