I'm running Sequel Pro 0.9.9.1 and can connect to a remote mySQL (v 14.14) database hosted on a server that only allows SSH connections. When I connect via Sequel Pro, I only need to fill out the ssh user and password to connect without issue. I am able to access all databases in this manner.
I then try to connect to the database in R (2.14.0) using RMySQL (0.9-3), but this command fails:
conn <- dbConnect(MySQL(), user="ssh_user", password="ssh_password", host="localhost")
with the error: "RS-DBI driver: (Failed to connect to database: Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)" regardless of if I use single quotes (suggested elsewhere), change the user and/or password to "root" or "", or substitute "127.0.0.1" for "localhost". If I substitute the server host for host in the R command, I am told I cannot access the server (which is true, it is configured to only be accessed via ssh).
What are the correct user, password and host to use to connect to a database accessed via ssh through Sequel Pro in this manner?
I've never done this, but I assume you could use SSH to tunnel the appropriate port, as discussed here: http://www.howtogeek.com/howto/ubuntu/access-your-mysql-server-remotely-over-ssh/ .
In brief, you would:
Tunnel the appropriate port through SSH, which by default would be
3306 for MySQL.
Use dbConnect() to connect to the MySQL server as
if it was on your local machine.
This bypasses the need for Sequel Pro. The tunnel essentially allows traffic on your local 3306 port to be tunneled through an SSH connection on port 22 between your local machine and the server and then forwarded to port 3306 locally on the server.
Related
I set up a remote SSH connection with Putty to a mysql datebase using a socket file and port 5001 (required by the provider). With mysql workbench I use the TCP/IP over SSH connection which works fine. Now I require to setup an ODBC connection using the mysql ODBC connector. Using just the setup with localhost/5001 and the dbuser/dbname results in a error 10061 can not connect to mySQL server.
What I am missing is how to setup this ODBC connection with the SSH parameters host, port and SSH username - similar as this is done in the mysql workbench. Is this at all possible in mysql connector?
Objective is to connect R to PostgreSQL using an SSH tunnel.
Just had unsuccessful tries with libraries RPostgreSQL and DBI. I'm not finding a way to pass along SSH tunneling parameters (proxy host, proxy user, and private key).
I wonder if there's a way to somehow specify those SSH parameters along in db query string? Maybe another way out?
Here's a code sample that I've used:
First, setup an ssh tunnel - this would be for an AWS EC2 instance:
ssh -i 'YOURKEY.pem' -N -L 1234:YOURDATABASEHOST:5432 YOURUSER#YOURAWSINSTANCE
Then in R:
library(RPostgreSQL)
conn <- dbConnect(RPostgreSQL::PostgreSQL(), dbname = 'MYREMOTEDBNAME', host = '127.0.0.1', port = 1234, password = 'MYREMOTEPASSWORD', user = 'MYREMOTEUSER')
As you can see, the key is to setup a tunnel between a remote instance of some kind and the remote database. Then you use this locally hosted tunnel (hence, 127.0.0.1 as your host) and the specified port (1234 in this case).
How can I create a SSH tunnel to a machine (RedHat Enterprise Linux) hosting a MongoDB (Version 3) and then run R scripts from my machine (windows) on the database?
I know how to connect to the machine via puTTY and then run an uploaded FCP transferred R script from the shell on the machine, however I want to perform the analysis from my PC so I can test my scripts quickly and export analyses and results easily.
This is adapted from an instruction I have for our remote MySQL SSH connections. The remote database server is configured to listen to its local address on port 27017. (127.0.0.1:27017). You would want to replace 10.10.10.10 with the IP address of the MongoDB server.
1. Install putty.exe
2. Start putty.
3. Sessions Tab:
3a. Set hostname like:
3b. <username#hostname>
3c. Eg: mongo_user#mongodb.server.com
4. Connection : SSH : Tunnels tab.
4a. Source port: 27017
4b. Destination: 10.10.10.10:27017
5. Sessions Tab
5a. Saved Session: Type name such as “MongoDB Server”
5b. Select [Save] button
On your windows client, you would use a connection string to connect to 127.0.0.1:27017 (the local source port you configured in the putty connection above)
edit to change 192.168.0.1 to 127.0.0.1 (wrong local/loopback address)
I have Meteor running on a local virtual machine on Windows which is accessible using the IP address of 192.168.56.111
When I use Robomongo, I use this IP address and point it to port 3001 and I an unable to connect.
Should I expect it to connect? If not, is there anything I need to do to get it to connect?
Setup SSH server on Windows and then simply create SSH tunnel:
ssh -L27018:192.168.56.111:3001 user#host
After that open Robomongo and connect to localhost:27018. That's it!
This technique I'm using successfully to connect to production database.
With meteor the database that runs is bound to 127.0.0.1, so it will not be accessible on other IPs. I think this was done for a security reason, though not sure.
You should use the local IP/127.0.0.1 instead of 192.168.56.11.
I got access via SSH (root access) to a Machine that's inside a network at my client's office.
I'm programming in my computer a PHP application that needs to integrate to LDAP. The LDAP server is in another server at my client's network and not accesible from outside, however I can perfectly access it via the server I can connect to via SSH.
My question is: IS there anyway I can make a tunnel and setup a port in my computer to get the traffic forwarded to the LDAP server using my SSH connection to one of the computers on the network?
Thanks!!!!
Yes, ssh has a "-L" option to create a tunnel. That option takes 3 parameters, separated by colons (:). Local listen port, remote host, remote port.
ssh -L 9999:ldapserver:389 user#otherhost
Where 9999 is the local port that the tunnel will be created on. The ldapserver:389 bit tells it where to connect to on the other side.
Then, tell your application to connect to localhost:9999 (or whatever port you choose) and it will be tunneled across.