/ Published in: Other
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
gateway = Net::SSH::Gateway.new( 'remotehost.com', 'username' ) port = gateway.open('127.0.0.1', 3306, 3307) # use cmd line to verify connection over ssh tunnel # mysql -u root -p -h 127.0.0.1 --port 3307 client = Mysql2::Client.new( host: "127.0.0.1", username: 'root', password: '', database: 'dbname', port: port ) results = client.query("SELECT * FROM projects") results.each do |row| p row end client.close