
You can kill the process by manually finding and typing in the pid or automatically by killing all pids matching your server name.

# Start the ssh connection to server "otherhost" To clarify my question, I would like to perform this entire workflow (establish a connection, download postgreSQL data) entirely in R without any steps in terminal. This probably means the server terminated abnormally RS-DBI driver: (could not Retrieve the result : server closed the connection unexpectedly System("ssh -T -p Port -L LocalPort:IP:RemotePort servername")Įrror in postgresqlExecStatement(conn, statement. Here is my attempt to do so, with accompanying error. However, I would like to do the first step - i.e., creating the ssh connection - in R, rather than in terminal.

This approach works fine, and I am able to download the data with no problems. I then connect to the postgres database in R.ĭriver <- dbDriver("PostgreSQL") # Establish database driverĬonnection <- dbConnect(Driver, dbname = "DBName", host = "localhost", port = LocalPort, user = "User")ĭata<-dbGetQuery(Connection,"SELECT * FROM remote_postgres_table") Ssh -p Port -L LocalPort:IP:RemotePort servername" I first open an ssh connection to the remote server in terminal.
#Postgres ssh tunnel code
My code looks like this (anonymized credentials). As part of my R workflow for one of my projects, I load in data from a postgreSQL table located on a remote server.
