#!/usr/bin/env ruby require 'yaml' require 'rubygems' require_gem 'net-ssh' $stdout.sync = true def help puts <<-USAGE This tool allows you to setup an ssh tunnel to a remote mySQL server Useage: dbssh <target> Please specify configuration in ~/.dbsshrc Example: example ~/.dbsshrc: server_name: server: servername.com.au username: user_id password: password_cleartext remote_port: 3306 local_port: 3307 USAGE exit end app_name = ARGV[0] || help $config = YAML::load(File.open(File.expand_path("~/.dbsshrc")))[app_name] puts "connecting to #{$config["server"]}" exec("ssh -2 -f -c blowfish -N -C #{$config["username"]}@#{$config["server"]} -L #{$config["local_port"]}/127.0.0.1/#{$config["remote_port"]}") puts "" puts "success!"
Never been to CodeSnippets before?
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
Script to setup ssh tunnel to a remote mysql server (See related posts)
You need to create an account or log in to post comments to this site.
Related Posts
» Creating a MySQL database an... in mysql databases users
» SSH tunneling for MySQL in mysql ssh tunneling remote
» MySQL launchd item for Mac O... in mysql osx 10.4 tiger launchd
» Creating a quick dump for yo... in mysql
» Looking for the MySQL socket in mysql
» Convert a db to UTF8 after u... in mysql
Snippets (source code soon to be available) developed by Peter Cooper and powered by Ruby On Rails