R language. Private GitLab. Unable to send userauth-publickey request Error - r

I can successfully access gitlab project using Git Bash or via R-studio with my credentials.
But when I try to install project using devtools it returns error.
Here is my code
creds = git2r::cred_ssh_key(publickey = "C:\\Users\\user\\.ssh\\id_rsa.pub", privatekey = "C:\\Users\\user\\.ssh\\id_rsa")
devtools::install_git("git#gitlab.mycompany.com:my_project.git", credentials = creds)
Here is log:
Downloading git repo git#gitlab.mycompany.com:my_projects/my_project.git
Installation failed: Error in 'git2r_clone': Failed to authenticate SSH session: Unable to send userauth-publickey request
I use R-Studio, Windows 7.

Issue was fixed by recreation of key

Related

failing to devtools::install_github() from an enterprise github account

I am trying to install an R package from an enterprise github account
devtools::install_github(
repo = "<owner>/<repo>",
host = "github.<org_name>.com/api/v3/",
auth_token = <my_github_pat>
)
I get this error message
Error: Failed to install '<repo>' from GitHub: HTTP error 404. Not Found Did you spell the repo owner ('<owner>') and repo name ('<repo>') correctly? - If spelling is correct, check that you have the required permissions to access the repo.
I have the correct spellings, and I think that I must have the required permissions because it's actually my repo: I can push and pull from the repo just fine. I am doing the install_github() as a test case so colleagues can install my package, but I can't make sense of this error message.
Literally just needed to drop the last "/" in the host string and this worked. SMH
devtools::install_github(
repo = "<owner>/<repo>",
host = "github.<org_name>.com/api/v3",
auth_token = <my_github_pat>
)

Installing a package from private GitLab server on Windows

I am struggling with installing a package from a GitLab repository on a Windows computer.
I found different hints but still have problems to install my package from GitLab. First of all, I generated a public and private key with puttygen.exe. The files need to be changed afterwards, I had to remove comments and stuff so they look like my the file on my Unix system. So now, both public and private key files have just a single line.
I tried to install my package via devtools::install_git which takes very long and I get the error message
Error: Failed to install 'unknown package' from Git:
Error in 'git2r_remote_ls': Failed to authenticate SSH session: Unable to send userauth-publickey request
And with devtools::install_gitlab I get a different error message and I somehow have the feeling, the link which gets generated doesn't fit to my GitLab server.
Error: Failed to install 'unknown package' from GitLab:
cannot open URL 'https://gitlab.rlp.net/api/v4/projects/madejung%2FMQqueue.git/repository/files/DESCRIPTION/raw?ref=master'
My complete code to test at the moment is
creds <- git2r::cred_ssh_key(publickey="~/.ssh/id_rsa_gitlab.pub",
privatekey="~/.ssh/id_rsa_gitlab")
devtools::install_git(
url='git#gitlab.rlp.net:madejung/MQqueue.git',
quiet=FALSE,
credentials=creds)
devtools::install_gitlab(
repo='madejung/MQqueue.git',
host='gitlab.rlp.net',
quiet=FALSE,
credentials=creds
)
My id_rsa_gitlab.pub file looks like this and is just a single line:
ssh-rsa AAAA....fiwbw== rsa-key-20200121
The id_rsa_gitlab file has just the code:
AAABA.....3WNSIAGE=
Update
On my Mac system it works as expected after installing the libssh2 library via homebrew and and recompiling git2r with install.packages("git2r", type = "source").
So the working code on my machine is:
creds <- git2r::cred_ssh_key(publickey="~/.ssh/id_rsa_gitlab.rlp.net.pub",
privatekey="~/.ssh/id_rsa_gitlab.rlp.net")
devtools::install_git(
url='git#gitlab.rlp.net:madejung/MQqueue.git',
quiet=FALSE,
credentials=creds
)
For some strange reason, the devtools::install_git call needs about a minute to fail in the end. I have no idea where the problem here is.
After struggling for almost a day, I found a solution I can live with...
I first created a PAT (Personal Access Token) in my gitlab account and granted full API access. For some reason the read_only access didn't worked and I am now tired to figure out what the problem is.
After this I had still problems to install my package and for some reason, the wininet setting for downloading doesn't work.
I used the command capabilities("libcurl") to check if libcurl is available on my windows, which was and tried to overwrite wininet to libcurl by using method='libcurl' in the install function. Somehow, this was not enough so I overwrote the options variable download.file.method directly.
options("download.file.method"='libcurl')
devtools::install_gitlab(
repo='madejung/MQqueue',
auth_token='Ho...SOMETHING...xugzb',
host='gitlab.rlp.net',
quiet=FALSE, force=TRUE
)

Secure Password Storage for R on (non-GUI) Linux Server

I'm working on a small team trying to put an R script onto an AWS EC2 instance that has RHEL7 installed. The problem is the library "keyring" which we use on our laptops doesn't work without a compatible keyring daemon, which I have been unable to get working on the EC2 instance.
[ec2-user#ip-10-XX-XX-XXX ~]$ gnome-keyring-daemon -r
** Message: couldn't connect to dbus session bus: Cannot autolaunch D-Bus without X11 $DISPLAY
** Message: Replacing daemon, using directory: /run/user/1000/keyring
GNOME_KEYRING_CONTROL=/run/user/1000/keyring
SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
[ec2-user#ip-10-XX-XX-XXX ~]$ R
...
[Previously saved workspace restored]
> keyring::key_set('test', 'test')
PASSWORD: ****
Error in warn_for_keyring(keyring) :
argument "keyring" is missing, with no default
In addition: Warning message:
In default_backend_auto() :
Selecting ‘env’ backend. Secrets are stored in environment variables
For now we're using an R environment file, but we'd prefer some formed of hashed storage. Can anyone recommend a method for secure key storage that we can use in production?

Error in BASH : oauth_listener() needs an interactive environment

I'm trying to run some Rscript via cron job.
I am using RGA package.
The error I get in terminal is:
Access token will be stored in the './ga-token.rds' file.
Error:
oauth_listener() needs an interactive environment.
Execution halted
My code is:
library(RGA)
authorize(client.id = ".......", client.secret = ".......", cache = "./ga-token.rds")
you need to download and install httpuv
install.packages ("httpuv").
after that
require("httpuv").
It's working:
rga_auth <- authorize(client.id = "XXXXXXX.apps.googleusercontent.com", client.secret = "XXXXXXXXXX")
Access token will be stored in the '.ga-token.rds' file.
Adding .ga-token.rds to .gitignore
Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
Authentication complete.

Authorize ShinyApps In Rstudio

I am trying to authorize my shinyapps account on my Rstudio console, but when I run the setAccountInfo() , i get the following error
Failed to connect to api.shinyapps.io port 443: Connection refused
I am under a proxy connection in my college.although i have run the following code to work under proxy and it used to work for installing packages from github etc. but to authorize its still not working
library(httr)
set_config(
use_proxy(url="10.3.100.207", port=8080)
)
i have even enabled internet2. but all the attempts are futile. any help ?
If you're running behind a proxy server, you'll want to configure the shinyapps package to use your proxy server. Checkout the docs in ?shinyapps::shinyappsProxies for more information, but in short you'll likely want to do:
Sys.setenv(http_proxy = "http://username:password#proxy.example.com:8080")
It can be helpful to put this command in your .Rprofile so its runs everytime you launch R.

Resources