SSH Key not found when publish code r connect.

Hello Every one,

i would like to post an issue that i face with a code.

test_oc<-data.frame(column1=c(1,2,3),column2=c("ceci","est","un test"))
write.csv(test_oc, file="test_OC_4",na="",row.names=FALSE,quote = FALSE)
system ("ls -al")
system ("chmod 600 ~/.ssh/id_rsa2"  )
system("scp -v -i id_rsa2 test_OC_4  test@.........:/home/test/Input/.")

when running the code on my machine the code is working properly .

i mean a file is generated on the server that i want.

The issue is that when a publish the code on r connect i got the following error :

Warning: Identity file id_rsa2 not accessible: No such file or directory.
Host key verification failed.
lost connection

Thank you in advance for your help.

Werner.

Hi Werner,

By default any code deployed to RStudio connect is executed by the rstudio-connect user, c.f. Process Management - RStudio Connect: Admin Guide, though that can be changed. But regardless of who executes the code, the SSH key needs to be available for that user on the server running Rstudio Connect. So one possibility would be to transfer the key via scp.

But then if we put the ssh key in the rstudio-connect/.ssh , anybody can use it if they have the private key name.

best regards,

O.

That's correct. Some alternatives:

  • Include the SSH key in the bundle that you publish, making it artifact specific.
  • Put the SSH key into an environment variable in Connect, again making it artifact specific.
  • Create an additional RunAs user on Connect and put the SSH key into that user's HOME. An admin on Connect will then be able to select this special RunAs user for those artifacts that need it.

thank you ! with Olivier is working now.