I'm trying to connect to a SFTP server. It is an encrypted server that uses FIPS mode. I am able to connect and perform file transfer through WinSCP, FileZilla, and through bash sftp commands with no problems.
But, I cannot, access this same SFTP from R using RCurl (R version=3.3.2, RCurl version=1.95-4.10, windows 10). This is what my code looks like and the error message that is being produced:
RCurl::ftpUpload(what="path/to/my/local/file.ext",
to = "sftp://my.eftp.server:portNumber/path/to/my/file.ext",
userpwd = "user:password",
.opts=curlOptions(verbose=TRUE))
The error message is:
* Trying ###.###.###.##...
* Connected to my.eftp.server (###.###.###.##) port ## (#0)
* Failure establishing ssh session
* Closing connection 0
Error in function (type, msg, asError = TRUE) :
Failure establishing ssh session
Any help would be wonderful. I've referenced the following with no luck:
sftp with R - sftp not a protocol with RCurl,
Using RCurl with SFTP
and the RCurl documentation (and other links).
I've also tried:
RCurl::ftpUpload(what="path/to/my/local/file.ext",
to = "sftp://user:password#my.eftp.server:portNumber/path/to/my/file.ext",
.opts=curlOptions(verbose=TRUE))
Also, I've checked my curlVersion()$protocols and scp and sftp protocols are listed (with the others).
Related
I am attempting to connect to an SFTP site to pull data. It used to work, but for some reason, it stopped working a couple of weeks ago. The owners of the SFTP say nothing has changed on their end, and I can pull data easily without error using WinSCP.
protocol <- "sftp"
server <- "sftp.xxxx.net"
userpwd <- "user:password"
file <- "/public/bpus_dailytx.csv"
url <- paste0(protocol, "://", server, file)
data <- getURL(url = url, userpwd=userpwd, verbose = TRUE)
When I run this, I now get the following info:
* Trying xxx.xx.xx.xxx...
* Connected to sftp.xxxx.net (xxx.xx.xx.xxx) port 22 (#0)
* SSH MD5 fingerprint: 34rh3ie93hhr39hhdik3
* SSH authentication methods available: publickey,keyboard-interactive
* Using SSH public key file '(nil)'
* Using SSH private key file ''
* SSH public key authentication failed: Unable to extract public key from private key file: Unable to open private key file
* No identity would match
* Authentication failure
* Closing connection 0
Error in function (type, msg, asError = TRUE) : Authentication failure
It connects OK but then the authentication fails. Any ideas what could be going on here? Again, this code used to work but something has changed. What are some other ways I can attempt to pull the data other than this?
Edit: WinSCP screenshots:
It is difficult to say why your code stopped working because we do not have enough information about configurations (both on your machine and on the server) when it was working.
Because your keyfile was not in the proper format for RCurl, my leading hypothesis is that although the server folks said nothing changed on their end, I think they removed the password authentication option. That is because your code attempts password authentication only. If password authentication were still available, the one line in your output would look something like this:
SSH authentication methods available: publickey,password,keyboard-interactive
It is, as you noted, now:
SSH authentication methods available: publickey,keyboard-interactive
Therefore, the solution here was to convert your keyfile from PuTTY to OpenSSH format using PuTTYgen and then use the following RCurl code pointing to your new keyfile:
protocol <- "sftp"
server <- "sftp.xxxx.net"
file <- "/public/bpus_dailytx.csv"
url <- paste0(protocol, "://", server, file)
keypasswd <- "your_keypasswd"
ssh.private.keyfile = "your_path_to_keyfile"
username <- "your_username"
data <- getURL(url = url, keypasswd = keypasswd, ssh.private.keyfile = ssh.private.keyfile, username = username, verbose = TRUE)
And I will add a special thanks to #Tensibai for the assistance. It would have taken me way longer to arrive at this solution without their insight with the keyfile format.
I am looking to connect to a server using the mongolite package of R but I have the following error
Error: No suitable servers found (serverSelectionTryOnce set): [connection timeout calling ismaster on 'XXX.XX.XX.XXX:XXXX'] where XX are the IP of the server.
Additionaly I have tried to use a proxy to reach out the required server without success.
I have try to create a .Renvion file in my user/Home
and adding the folowing line into this conf file
options(internet.info = 0)
http_proxy=//proxy.serv:0000/ where 0000 are the port of the proxy
Then I am calling the require serveur with its URL in the command line below
mongo(url = "mongodb://XXX.XX.XX.XXX:XXXX", db = "TEST",collection = "TEST1")
without success.
I have allowed the firewall security to the required serveur going forward.
Any Help?
I am searching for a robust solution to perform extensive computations on a remote server, dedicated to computational tasks. The server is on Windows 2008 R2 and has R x64 3.4.1 installed on it. I've searched for free solutions and am now focusing on the Rserver/RSclient packages solutions.
However, I can't connect any client (using RSclient) to the instanced server.
This is how I'm proceeding at the moment from the server side:
library(Rserve)
run.Rserve(config.file = "Rserv.conf")
using the following Rserv.conf file:
port 6311
remote enable
plaintext enable
control enable
r-control enable
The server is now intanciated using the Rsession (It's a bit ugly, but will change that latter on):
running Rserve in this R session (pid=...), 1 server(s)
Now, i'm trying to connect using a remote computer (Client-side) using:
library(RSclient)
c = RS.connect(host = "...")
The connection then seems to succeed, checking for c:
> c
Rserve QAP1 connection 0x000000000fbe9f50 (socket 764, queue length 0)
The error occurs when i try to eval anything, for example:
> RS.server.eval(c,"0<1")
Error in RS.server.eval(c, "0<1") : command failed with status code 0x4e: no control line present (control commands disabled or server shutdown)
I've read the available guides but still failed in connecting. What is wrong? It seems to be related to control lines but I authorized them in the config file.
for me the problem was solved by initiating the Rserve instance with the command:
R CMD Rserve --RS-port 9000 --RS-enable-remote --RS-enable-control
instead of starting it in the R environment (library(Rserve), run.Rserve(config.file = "Rserv.conf")). You may try this on Windows as well.
Refer https://github.com/s-u/Rserve/wiki/rserve.conf.
port 6311
remote enable -> it should be remote true
plaintext enable
control enable
r-control enable
Likewise refer the link and try with actual values
I am having trouble creating an SSL connection using RPostgreSQL to an AWS hosted PostgreSQL database.
Here is what I've tried so far:
Created the PostgreSQL database on AWS.
Set the database parameter "rds.force_ssl" to 1.
Downloaded the AWS public key from https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem
Test the connection from a windows command prompt with psql (it works).
Executed the following in R:
library(RPostgreSQL)
cert <- paste0("C:/Users/johnr/Downloads/", "rds-combined-ca-bundle.pem")
dbname <- paste0("dbname=", "flargnog", " ", "sslrootcert=", cert, " ", "sslmode=verify-full")
host <- "xxxxxx.xxxxx.us-region-2.rds.amazonaws.com"
con <- dbConnect(dbDriver("PostgreSQL"), user="username", host=host, port=5432, dbname=dbname, password="abcd1234!")
I receive an error message after executing the last statement:
Error in postgresqlNewConnection(drv, ...) :
RS-DBI driver: (could not connect username#xxxxxx.xxxxx.us-region-2.rds.amazonaws.com on dbname "flargnog"
If I change the rds.force_ssl setting to 0 (and remove the ssl stuff from dbname) the connection works just fine.
I have looked at other posts on Stackoverflow related to this issue. This and this seem to indicate an SSL connection is not possible due to issues with RPostgreSQL. However, this post indicates that you can.
Any guidance would be appreciated!
You can try to ssh to the rds instance using e.g. putty and port-forward your local port 5432 to the remote port 5432. Once the ssh connection is open in R just connect to localhost:5432...
Here is how to port-forward using putty:
http://www.akadia.com/services/ssh_putty.html
Here is how this works via command-line:
https://gist.github.com/magnetikonline/3d239b82265398568f31
P.S.: Make sure your instance is in a security-group that accepts ssh connections - port 22
I need to get config file from the Linux server that is authenticated using ssh keys. I am stuck with "Callback returned error" message.
conf = scp(host="10.10.10.10", path="/home/admin/codebase/config.txt",
user="admin", keypasswd = "", verbose=TRUE,
key=c("C:/echinn/.ssh/my_public_key", "C:/echinn/.ssh/my_private_key"))
I get the following output
* Trying 10.10.10.10...
* Connected to 10.10.10.10 (10.10.10.10) port 22 (#0)
* SSH MD5 fingerprint: 8fa4562037d2f1e68c7ff419f9dc7656
* SSH authentication methods available: publickey,gssapi-keyex,gssapi-with-mic
* Using SSH public key file 'C:/echinn/.ssh/my_public_key'
* Using SSH private key file 'C:/echinn/.ssh/my_private_key'
* SSH public key authentication failed: Callback returned error
* Failure connecting to agent
* Authentication failure
* Closing connection 0
Error in function (type, msg, asError = TRUE) : Authentication failure
I also tried with "getURL()" but ended up with the same error. I am able to successfully connect using putty and WinSCP with (.ppk format of) the same public/private keys.
On the Linux server /var/log/secure I see the following for every execution
sshd[xxxx]: Connection closed by x.x.x.x [preauth]
From the R Documentation for the scp function, it looks like your key does not have a passphrase, so try setting keypasswd = NA or removing the argument altogether.