meztez / plumberDeploy

Other
50 stars 12 forks source link

Error: Authentication with ssh server failed #42

Closed hjzhou988 closed 2 months ago

hjzhou988 commented 2 months ago

System details

Output of sessioninfo::session_info()():

# sessioninfo::session_info()
─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.4.1 (2024-06-14)
 os       macOS Sonoma 14.4
 system   x86_64, darwin20
 ui       RStudio
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       Asia/Shanghai
 date     2024-07-16
 rstudio  2024.04.2+764 Chocolate Cosmos (desktop)
 pandoc   3.1.11 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/x86_64/ (via rmarkdown)

─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────
 ! package       * version date (UTC) lib source
 P analogsea     * 1.0.7.2 2023-04-19 [?] CRAN (R 4.4.0)
 P askpass         1.2.0   2023-09-03 [?] CRAN (R 4.4.0)
 P cli             3.6.3   2024-06-21 [?] CRAN (R 4.4.0)
 P credentials     2.0.1   2023-09-06 [?] CRAN (R 4.4.0)
 P curl            5.2.1   2024-03-01 [?] CRAN (R 4.4.0)
 P digest          0.6.36  2024-06-23 [?] CRAN (R 4.4.0)
 P DT              0.33    2024-04-04 [?] CRAN (R 4.4.0)
 P evaluate        0.24.0  2024-06-10 [?] CRAN (R 4.4.0)
 P fastmap         1.2.0   2024-05-15 [?] CRAN (R 4.4.0)
 P glue            1.7.0   2024-01-09 [?] CRAN (R 4.4.0)
 P htmltools       0.5.8.1 2024-04-04 [?] CRAN (R 4.4.0)
 P htmlwidgets     1.6.4   2023-12-06 [?] CRAN (R 4.4.0)
 P httr            1.4.7   2023-08-15 [?] CRAN (R 4.4.0)
 P jsonlite        1.8.8   2023-12-04 [?] CRAN (R 4.4.0)
 P knitr           1.47    2024-05-29 [?] CRAN (R 4.4.0)
 P lifecycle       1.0.4   2023-11-07 [?] CRAN (R 4.4.0)
 P magrittr        2.0.3   2022-03-30 [?] CRAN (R 4.4.0)
 P openssl         2.2.0   2024-05-16 [?] CRAN (R 4.4.0)
 P plumberDeploy * 0.2.1   2021-03-22 [?] CRAN (R 4.4.0)
 P R6              2.5.1   2021-08-19 [?] CRAN (R 4.4.0)
   renv            1.0.7   2024-04-11 [1] CRAN (R 4.4.0)
 P rlang           1.1.4   2024-06-04 [?] CRAN (R 4.4.0)
 P rmarkdown       2.27    2024-05-17 [?] CRAN (R 4.4.0)
 P rstudioapi      0.16.0  2024-03-24 [?] CRAN (R 4.4.0)
 P sessioninfo     1.2.2   2021-12-06 [?] CRAN (R 4.4.0)
 P ssh             0.9.1   2023-10-16 [?] CRAN (R 4.4.0)
 P stringi         1.8.4   2024-05-06 [?] CRAN (R 4.4.0)
 P stringr         1.5.1   2023-11-14 [?] CRAN (R 4.4.0)
 P sys             3.4.2   2023-05-23 [?] CRAN (R 4.4.0)
 P xfun            0.45    2024-06-16 [?] CRAN (R 4.4.0)
 P yaml            2.3.8   2023-12-11 [?] CRAN (R 4.4.0)

 [1] /Users/huajunzhou/Documents/HuPharm/git/hupharm/Binchen/renv/library/macos/R-4.4/x86_64-apple-darwin20
 [2] /Users/huajunzhou/Library/Caches/org.R-project.R/R/renv/sandbox/macos/R-4.4/x86_64-apple-darwin20/2edc1867

 P ── Loaded and on-disk path mismatch.

Example application or steps to reproduce the problem

plumberDeploy::do_provision(keyfile = [[private.key.file]])

plumberDeploy::do_deploy_api(droplets()[[1]], "date", [[path_to_plumber.R]], 8000, docs = TRUE, keyfile = [[private.key.file]] )

Describe the problem in detail

Hi, I tried to use do_provision() to deploy a sample API with my private key, but it returns the "Error: Authentication with ssh server failed", even though the new server key was generated. What could be the cause for this error? Also I tried to deploy the example "date" API with the command above, but still failed with error: "mv: cannot move '/tmp/JLOUIHVOWC/api' to '/var/plumber/date': No such file or directory Error: ssh failed" So I manually created a /var/plumber/ directory in the server, and redo the do_deploy_api command. The error then becomes: "Error: ssh failed"

How do I solve this issue?

meztez commented 2 months ago

@hjzhou988 what happens when you follow step 1 to 4 from the readme setup section?

hjzhou988 commented 2 months ago

I went through 1 to 4, and analogsea::droplets() can show me not only the initial active server that I created on digital ocean, but also the plumber servers that created by plumberDeploy::do_provision().

meztez commented 2 months ago

I'll try to replicate, thanks for the response and report.

meztez commented 2 months ago

@hjzhou988 would you mind installing the github version and testing if it works for you? I will publish to CRAN after that.

hjzhou988 commented 1 month ago

@meztez Thank you! However, after I installed the github version, it's still not working. It seems to be related to nginx:

> plumberDeploy::do_deploy_api(droplets()[[2]], "date", "test_api/", 8000, docs = TRUE, keyfile = "id_digital_ocean",overwrite = T )
stopping service: plumber-date
disabling service: plumber-date
Removed /etc/systemd/system/multi-user.target.wants/plumber-date.service.
removing service: plumber-date
removing config: plumber-date
rm: cannot remove '/etc/nginx/sites-available/plumber-apis/date.conf': No such file or directory
reloading nginx: plumber-date
Failed to reload nginx.service: Unit nginx.service not found.
reloading plumber folder: plumber-date
[100%] /Users/huajunzhou/Documents/Model_recommend/test_api/plumber.R
/tmp/XOGEHRPHFH
[100%] /private/var/folders/x1/_wrl1b7d19lbns1c894kf9q00000gp/T/RtmpaSqfKg/file154bae42ac58
/etc/systemd/system/plumber-date.service
Failed to start plumber-date.service: Unit plumber-date.service has a bad unit file setting.
See system logs and 'systemctl status plumber-date.service' for details.
Error: ssh failed
systemctl start plumber-date && sleep 1
meztez commented 1 month ago

That would be an error with starting the plumber service, most likely due to a missing R library. It will depends on the content of the plumber R file.

hjzhou988 commented 1 month ago

You mean the plumber.R file? In the file, I only included the example API:

#* @get /
function() {
  Sys.Date()
}
meztez commented 1 month ago

I wonder if the do_provision default exemple = TRUE already added the service to the machine?

hjzhou988 commented 1 month ago

Good point! I didn't realize that I didn't try the new do_provision() function. I just tried it, and it established a server different from previous. I tried typing in

systemctl status plumber-hello

The example API is running. And I disabled and stopped the plumber-hello service, and use do_deploy_api() to upload the "date" API, and now it is running. Thank you very much for your update!