Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows users can't SSH into VM #35

Closed
nickshffer opened this issue Feb 3, 2017 · 24 comments
Closed

Windows users can't SSH into VM #35

nickshffer opened this issue Feb 3, 2017 · 24 comments
Labels

Comments

@nickshffer
Copy link

First: Great package. Really exciting stuff.

On a Windows 10 machine:

I'm having trouble accessing the VM created in either of the rstudio server templates (rstudio-hadleyverse and rstudio). After creating either one, I am able to SSH via the browser, SSH via gcloud, SSH via putty to the appropriate user@externalIP (after adding the appropriate keys and checking to make sure the public key is in both the project metadata store and on the VM's authorized keys list itself) but I cannot access RStudio server at port 8787 of the external ID nor can I run command like gce_push_registry

Public SSH key uploaded to instance Warning: Permanently added '104.197.245.222' (RSA) to the list of known hosts. Permission denied (publickey). Error: ssh failed ssh -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=C:\Users\Nick\AppData\Local\Temp\RtmpU5tD1m/hosts -i C:\Users\Nick\.ssh\google_compute_engine.ppk [email protected] "docker commit rstudio gcr.io/sandbox-157602/my_rstudio" In addition: Warning message: running command 'ssh -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=C:\Users\Nick\AppData\Local\Temp\RtmpU5tD1m/hosts -i C:\Users\Nick\.ssh\google_compute_engine.ppk [email protected] "docker commit rstudio gcr.io/sandbox-157602/my_rstudio"' had status 255

Similarly, as I'm sure you could guess, I cannot connect from the command line with simple commands like don't work (verbose output included)

C:\Users\Nick\AppData\Local\Google\Cloud SDK>ssh -vT -i C:\Users\Nick\.ssh\google_compute_engine.ppk [email protected] "echo foo" OpenSSH_7.3p1 Microsoft_Win32_port_with_VS, OpenSSL 1.0.2d 9 Jul 2015 debug1: Connecting to 104.197.245.222 [104.197.245.222] port 22. debug1: socket:460, io:00000257265B2EE0, fd:3 debug1: Connection established. debug1: permanently_set_uid: 0/0 debug1: open - handle:00000000000001D0, io:00000257265B3880, fd:4 debug1: close - io:00000257265B3880, type:2, fd:4, table_index:4 debug1: key_load_public: No such file or directory debug1: identity file C:\Users\Nick\.ssh\google_compute_engine.ppk type -1 debug1: open - CreateFile ERROR:2 debug1: key_load_public: No such file or directory debug1: identity file C:\Users\Nick\.ssh\google_compute_engine.ppk-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_7.3p1 Microsoft_Win32_port_with_VS Nov 29 2016 debug1: Remote protocol version 2.0, remote software version OpenSSH_7.3 debug1: match: OpenSSH_7.3 pat OpenSSH* compat 0x04000000 debug1: Authenticating to 104.197.245.222:22 as 'nickshffer' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: [email protected] debug1: kex: host key algorithm: rsa-sha2-512 debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ssh-rsa SHA256:7Tlsx+RlXnmXw8ldXRJ/8Rb6E1HCFpGtl8RqA/cO39Y debug1: Host '104.197.245.222' is known and matches the RSA host key. debug1: Found key in C:\Users\Nick/.ssh/known_hosts:1 debug1: rekey after 134217728 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: rekey after 134217728 blocks debug1: SSH2_MSG_NEWKEYS received debug1: close - io:00000257265B3670, type:2, fd:4, table_index:4 debug1: SSH2_MSG_EXT_INFO received debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512> debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Trying private key: C:\Users\Nick\.ssh\google_compute_engine.ppk debug1: open - handle:00000000000001D0, io:00000257265B3040, fd:4 debug1: close - io:00000257265B3040, type:2, fd:4, table_index:4 Enter passphrase for key 'C:\Users\Nick\.ssh\google_compute_engine.ppk': debug1: No more authentication methods to try. Permission denied (publickey).

Any thoughts?

@MarkEdmondson1234
Copy link
Collaborator

Thanks for the feedback @nickshffer , it all helps to make the tools better for everyone. :)

I believe this is related to the issue of running any SSH commands on Windows (#32 ) that is tough for me to test at the moment. It looks as if the SSH command fails to authenticate on your machine.

It does though look like you can invoke an SSH client with ssh - could you include what you installed to get that working? Then I guess its that SSH client that needs some config to get it to connect (does it work for other servers?) - the error messages looks like it can't find your auth keys, so perhaps that is all that is needed: it asks for a passphrase - perhaps you need to generate a key without a passphrase (just push enter when it asks) and use that instead?

All the commands involving docker (like gce_push_registry) rely on using SSH, and the SSH relies on being able to issue system commands to your OS that start with ssh, so if that fails you can't use those features.

I'd like at least some documentation on how to get around this on Windows, since on linux/OSX it comes with SSH.

So, I'm looking for some OS-agnostic way to use SSH. It may be that the best way to do that is to launch a helper VM that has SSH installed, or go via the browser, or maybe even include an SSH client in the package for Windows users. Or perhaps just say its not supported for Windows, but that sucks a bit.

@MarkEdmondson1234
Copy link
Collaborator

Possible solution here #32

@nickshffer
Copy link
Author

I'll follow up in #32 for the SSH issue but I'm curious if you have any insight into why port 8787 on the VM's IP is not accessible. What are the default firewall setting for the VMs created with the RStudio Server templates? If you don't know off hand I can SSH (with the browser) into one later and poke around.

@MarkEdmondson1234
Copy link
Collaborator

They should be on port 80 e.g. Via just the IP address in your browser. They are launched via docker with port 8787 mapped to 80.

@MarkEdmondson1234
Copy link
Collaborator

You can see the cloudconfig files that are used for the templates here https://github.com/cloudyr/googleComputeEngineR/tree/master/inst/cloudconfig

@MarkEdmondson1234 MarkEdmondson1234 changed the title Having trouble accessing VM Windows user's can't SSH into VM Feb 18, 2017
@MarkEdmondson1234 MarkEdmondson1234 changed the title Windows user's can't SSH into VM Windows users can't SSH into VM Feb 18, 2017
@chlorenz
Copy link

Hi,

Windows 8 user here. I've tried to use the SSH client that comes with RStudio and can be found in C:/Program Files/RStudio/bin/msys-ssh-1000-18 by adding it to the path (as suggested in #32).

> vm <- gce_vm(template = "rstudio-hadleyverse",
+ name = "rstudio-test",
+ username = "X", password = "X",
+ predefined_type = "n1-highmem-2")
2017-02-19 10:12:16> Creating template VM
2017-02-19 10:12:19> Checking operation...PENDING
2017-02-19 10:12:29> Operation running...
2017-02-19 10:12:49> Operation complete in 16 secs
2017-02-19 10:12:50> External IP for instance rstudio-test : X.X.X.X
2017-02-19 10:12:50> ## rstudio-hadleyverse running at X.X.X.X
2017-02-19 10:12:50> You may need to wait a few minutes for the inital docker container to 
            download and install before logging in.
2017-02-19 10:12:50> VM running

Add the SSH keys to the instance:

> vm <- gce_ssh_addkeys(username = "X",
+ instance = vm,
+ key.pub = "ssh-key.pub",
+ key.private = "ssh-key")
2017-02-19 10:15:02> Using ssh-key files given as ssh-key.pub / ssh-key

This does get me past authentication:

> gce_ssh(vm, "echo foo")
Warning: Permanently added 'X.X.X.X' (RSA) to the list of known hosts.
foo
[1] TRUE

But more complicated commands fail:

> containers(vm)
bash: /tmpgcer_cmd44ab05d4e2521: Read-only file system
Error: ssh failed
ssh -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=C:\Users\X\AppData\Local\Temp\RtmpkrqjVJ/hosts -i D:\X\ssh-key [email protected] "docker ps -qa > /tmp\gcer_cmd44ab05d4e2521"
In addition: Warning message:
running command 'ssh -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=C:\Users\X\AppData\Local\Temp\RtmpkrqjVJ/hosts -i D:\X\ssh-key [email protected] "docker ps -qa > /tmp\gcer_cmd44ab05d4e2521"' had status 1 

It seems like the forward slash in /tmp\gcer_cmd44ab05d4e2521 is the offender?

> gce_push_registry(vm, 
+                   save_name = "my_test_container2",
+                   container_name = "rstudio")
sha256:ada5f8a584bc8256b39b5e438c906be6ed33cdf600e40ed...
2017-02-19 10:21:35> Uploading to Google Container Registry: https://console.cloud.google.com/kubernetes/images/list?project=X
[1] "gcr.io/X/my_test_container2"

Even though this does not return an error, the container never gets pushed.

@MarkEdmondson1234
Copy link
Collaborator

@chlorenz great feedback thanks! This is fixable then, great, will take a look. Although we can avoid SSH in most cases, it would be great to have the SSH option there for Windows too.

@MarkEdmondson1234
Copy link
Collaborator

@chlorenz Ok I've pushed a tiny fix that should sort out the forward slash issue.

In case the gce_push_registry() command is a separate issue, you can see the output more if you pass wait=TRUE:

> gce_push_registry(vm, 
                   save_name = "my_test_container2",
                   container_name = "rstudio", wait = TRUE)

If still no joy then log in via gce_ssh_browser() or via the web UI and run on the VM outside of any docker containers:

## see if the image was made ok
## should see the build image with your tag gcr.io/X/my_test_container2
docker images -a

## do the push manually
docker push gcr.io/X/my_test_container2

If that fails you may need to auth with docker first before pushing:

/usr/share/google/dockercfg_update.sh

And you can see in docker logs what may have errored in build:

docker logs

@chlorenz
Copy link

Thanks @MarkEdmondson1234.

Re the gce_push_registry() issue, wait=TRUE did the trick:

> gce_push_registry(vm,
+ save_name = "my_test_container2",
+ container_name = "rstudio", wait = TRUE)
sha256:eafa05986fd2aad02e0cbd8c628ddd4d21d9be14849...
2017-02-19 21:32:08> Uploading to Google Container Registry: https://console.cloud.google.com/kubernetes/images/list?project=X
The push refers to a repository [gcr.io/X/my_test_container2]
08ba5bd1a46d: Preparing
2c982ac64dea: Preparing
82841b298540: Preparing
60d115eebfec: Preparing
a2ae92ffcd29: Preparing
2c982ac64dea: Pushed
08ba5bd1a46d: Pushed
a2ae92ffcd29: Pushed
82841b298540: Pushed
60d115eebfec: Pushed
latest: digest: sha256:357db0dc5c814be78c4cb9b611efa9a7203ea3d3c8d0f... size: 1371
[1] "gcr.io/X/my_test_container2"

Re the \:
Unfortunately this is how tempfile() behaves on (my) Windows:

> tempfile("gcer_cmd", "")
[1] "\\gcer_cmd5c2039f230d"

So the error persists. An ugly patch would be to use

> gsub("\\\\", "/", tempfile("gcer_cmd", ""))
[1] "/gcer_cmd5c20600f7047"

Then the following error is thrown:

> containers(vm)
bash: line 0: cd: C:/Users/X/AppData/Local/Temp/Rtmpkzgm3pdownload5c20641219a: No such file or directory
Error: ssh failed
ssh -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=C:\Users\X\AppData\Local\Temp\Rtmpkzgm3p/hosts -i D:\X\ssh-key [email protected] 'cd /tmp && tar cz gcer_cmd5c20431d46ed' | (cd C:/Users/X/AppData/Local/Temp/Rtmpkzgm3p\download5c20641219a && tar xz)
In addition: Warning message:
running command [...] had status 1 

So I poked around a little further. The directory does in fact not exist, but I can see you are calling dir.create(local_tempdir) in line 233 in ssh.R.
Please note that

dir.create("C:/Users/X/AppData/Local/Temp/Rtmpkzgm3p\\download5c20641219a")

works, so my best guess is the directory is created initially but does not persist?

If I understand this correctly, what this does is piping the output of ssh into the local folder and un-tarring it. This will lead to the issue that there is no tar on Windows by default :)

@MarkEdmondson1234
Copy link
Collaborator

Thanks for testing @chlorenz - pushed a small change so the file path should now work.

The capture text issue is only used some SSH derived commands such as containers(), only those that use gce_ssh(capture_text = TRUE). Things like docker_run should work now as they don't capture the SSH text back to an R object.

I will look around for the best way to tackle the piping on a Windows machine.

@chlorenz
Copy link

Great, can confirm it works.
Thank you @MarkEdmondson1234, this is a great package, keep up the good work.

@MarkEdmondson1234
Copy link
Collaborator

Thanks @chlorenz :) - could you just try the containers(vm) function again on the latest version, as I have removed the tar for Windows so now capture_text=TRUE should also work.

@chlorenz
Copy link

Please correct me if I'm wrong here: There is a line missing in gce_ssh_download() in the Windows else branch and it could be something like

      sprintf("'cat %s/%s'", dirname(remote), basename(remote)),

(there might be a better way to do it).
At that point it gets a bit hairy. The ssh command fails:

> containers(vm)
bash: C:/Users/X/AppData/Local/Temp/RtmpGahWJs/downloadtdSRHSHu5QfN9rn/gce_cmdOMvf4UlBwRVRZuC: No such file or directory
Error: ssh failed
ssh -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=C:\Users\X\AppData\Local\Temp\RtmpGahWJs/hosts -i D:\X\ssh-key [email protected] 'cat /tmp/gce_cmdOMvf4UlBwRVRZuC' > "C:/Users/X/AppData/Local/Temp/RtmpGahWJs/downloadtdSRHSHu5QfN9rn/gce_cmdOMvf4UlBwRVRZuC"
In addition: Warning message: [...] had status 1

(ignore for a second that I've changed local_tempdir <- file.path(local_dir, paste0("download", idempotency())) here).
However, copy and pasting the same command to a cmd prompt works, so system() fails but manually executing the same command works.
The only thing I could see it influencing were the quotes, so I tried:

      # shQuote(local_tempfile)
      "'local_tempfile'"

And indeed, it works!
But only one step closer since now

> containers(vm)
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
  cannot open file 'C:\Users\X\AppData\Local\Temp\RtmpGahWJs\gcer_cmd5bd6c1aaf5c71': No such file or directory

As you can see the \download... directory was lost.
I don't know why and haven't thought about it, if I had to guess I would say file.rename() might not behave as expected?
Nearly there!

@chlorenz
Copy link

Hi there,

Sorry about the red herring with the quotes, this was definitely a late night cognitive failure.

I did one more modification to get fully Windows compatible paths:

  local_tempfile <- gsub("/", "\\\\", local_tempfile)

After this the SSH command runs through. However, no output is stored 😄
So

system("ssh -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=C:\\Users\\X\\AppData\\Local\\Temp\\RtmpKQs6qA/hosts -i D:\\X\\ssh-key [email protected] 'cat /tmp/gce_cmdVM8VQEz4xMV7Syb' > \"C:\\Users\\X\\AppData\\Local\\Temp\\RtmpKQs6qA\\downloadnVSI8434JJnSuPo\\gce_cmdVM8VQEz4xMV7Syb\"")

does not fail but does also not store the output. Executing manually works fine.
I think I've found the culprit (from help(system)):

Not all Windows executables properly respect redirection of output, or may only do so from a console application such as Rterm and not from Rgui: for example, ‘fc.exe’ was among these in the past, but we have had more success recently.

@chlorenz
Copy link

Okay, so shell() does the proper redirection on (my) Windows machine.

@MarkEdmondson1234
Copy link
Collaborator

Thanks so much for testing this out, do you have a full example of using shell() ? I have an if statement for Windows users so can put anything in there that works.

@MarkEdmondson1234
Copy link
Collaborator

Hmm I can't even invoke shell on OSX :) If I put it in, it needs testing on Windows.

@MarkEdmondson1234
Copy link
Collaborator

@chlorenz ok I have moved everything to use system2 as that is supposed to be better cross platform that system. At the very least its a lot cleaner code to maintain.

@chlorenz
Copy link

@MarkEdmondson1234 Sorry to disappoint. system2() doesn't work at all for me, even gce_ssh() fails:

> gce_ssh(vm, "echo foo")
Error: ssh failed
ssh -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=C:\Users\X\AppData\Local\Temp\RtmpWmvSMF/hosts -i D:\X\ssh-key [email protected] "echo foo"
In addition: Warning message:
running command '"ssh -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=C:\Users\X\AppData\Local\Temp\RtmpWmvSMF/hosts -i D:\X\ssh-key [email protected] \"echo foo\""' had status 127 

However shell() seems to do the job. In do_system()

status <- shell(cmd, wait = wait)

then containers(vm) does indeed return information about the container!

@MarkEdmondson1234
Copy link
Collaborator

MarkEdmondson1234 commented Feb 25, 2017

@chlorenz can I check what version of R you are using? I can't find any reference to shell()other than from R version 2.1 here http://astrostatistics.psu.edu/datasets/R/html/base/html/shell.html

Run sessionInfo()

> sessionInfo()
R version 3.3.0 (2016-05-03)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.12.3 (unknown)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] googleComputeEngineR_0.1.0.9000

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.9            codetools_0.2-14       listenv_0.6.0          future_1.2.0          
 [5] crayon_1.3.2           digest_0.6.11          withr_1.0.2            mime_0.5              
 [9] R6_2.2.0               jsonlite_1.2           xtable_1.8-2           magrittr_1.5          
[13] httr_1.2.1.9000        curl_2.3               testthat_1.0.2         googleAuthR_0.4.0.9000
[17] devtools_1.12.0.9000   tools_3.3.0            shiny_1.0.0            httpuv_1.3.3          
[21] pkgload_0.0.0.9000     parallel_3.3.0         pkgbuild_0.0.0.9000    globals_0.7.1         
[25] memoise_1.0.0          htmltools_0.3.5        openssl_0.9.5         

MarkEdmondson1234 added a commit that referenced this issue Feb 25, 2017
@chlorenz
Copy link

@MarkEdmondson1234 I'm on the (almost) latest version of R

> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_United Kingdom.1252 
[2] LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] tools_3.3.1

The help for system() says

On Windows, system does not use a shell and there is a separate function shell which passes command lines to a shell.
https://stat.ethz.ch/R-manual/R-devel/library/base/html/system.html

@MarkEdmondson1234
Copy link
Collaborator

MarkEdmondson1234 commented Mar 2, 2017

@chlorenz I really think this is finally sorted now, as I got a chance to debug it on a Windows machine. In the end it came down to just quoting the file names correctly, so both Windows and Linux now use system2 which is nice.

> library(googleComputeEngineR)
> containers(vm)
2017-03-02 22:25:18> SSH keys already set
Token exists.
Request: https://www.googleapis.com/compute/v1/projects/blah/zones/europe-west1-b/instances/cron-master/
2017-03-02 22:25:18> Returning SSH keys on instance: 
2017-03-02 22:25:18> Username SSH key already exists
2017-03-02 22:25:18> ssh -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile='C:\Users\BLAH~1\AppData\Local\Temp\Rtmpu6InSB/hosts'  -i  'C:\Users\BLAH\.ssh\id_rsa' mark@X "docker ps -qa"
2017-03-02 22:25:19> Warning: Permanently added 'X' (RSA) to the list of known hosts.
2017-03-02 22:25:19> SSH keys already set
Token exists.
Request: https://www.googleapis.com/compute/v1/projects/blah/zones/europe-west1-b/instances/cron-master/
2017-03-02 22:25:19> Current local settings: , 
            private key: ,
            public key: 
2017-03-02 22:25:19> Returning SSH keys on instance: 
2017-03-02 22:25:19> Username SSH key already exists
2017-03-02 22:25:19> ssh -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile='C:\Users\BLAH~1\AppData\Local\Temp\Rtmpu6InSB/hosts'  -i  'C:\Users\BLAH\.ssh\id_rsa' mark@X "docker inspect d1978e8edfef"
2017-03-02 22:25:20> 
$rstudio
<container>
  ID:       d1978e8edfef 
  Name:     rstudio 
  Image:    gcr.io/blah/cron-master 
  Command:  /init 
  Host:     ==Google Compute Engine Instance==
  
  Name:                cron-master
  Created:             2017-02-25 07:09:19
  Machine Type:        f1-micro
  Status:              RUNNING
  Zone:                europe-west1-b
  External IP:         X
  Disks: 
               deviceName       type       mode boot autoDelete
  1 cron-master-boot-disk PERSISTENT READ_WRITE TRUE       TRUE

@chlorenz
Copy link

chlorenz commented Mar 8, 2017

@MarkEdmondson1234 That's fantastic, I've just had a chance to test and can confirm it works.

> gce_ssh(vm, "echo foo")
Warning: Permanently added 'X.X.X.X' (RSA) to the list of known hosts.
foo
[1] TRUE
> containers(vm)
2017-03-08 22:40:27> 
2017-03-08 22:40:28> 
$rstudio
<container>
  ID:       52950c9d9ddc 
  Name:     rstudio 
  Image:    rocker/rstudio 
  Command:  /init 
  Host:     ==Google Compute Engine Instance==
  
  Name:                rstudio-test
  Created:             2017-02-19 10:00:28
  Machine Type:        g1-small
  Status:              RUNNING
  Zone:                europe-west1-b
  External IP:         X.X.X.X
  Disks: 
                deviceName       type       mode boot autoDelete
  1 rstudio-test-boot-disk PERSISTENT READ_WRITE TRUE       TRUE

@camraynor
Copy link

Hi all, I've also been struggling with this issue while trying to set up a VM cluster using gce_vm_cluster and unfortunately the solutions suggested both here and in #32 have not been working.

Here is how my gce_vm_cluster is set up:

ssh <- list(
  "username" = "crayn",
  "ssh_overwrite" = FALSE,
  "key.pub" = file.path("C:","Users", "crayn", ".ssh", "id_rsa.pub"), 
  "key.private" = file.path("C:","Users", "crayn", ".ssh", "id_rsa")
)

vms <- gce_vm_cluster(
  vm_prefix = "attempt25-", 
  cluster_size = 1,
  docker_image = "rocker/r-parallel", 
  ssh_args = ssh,
  project = gce_get_global_project(), 
  zone = gce_get_global_zone()
)

I've gone through all the suggestions both here and in #32, but am getting the following error message:

2019-06-08 18:35:31> # Creating cluster with settings: template = r-base, dynamic_image = rocker/r-parallel, wait = FALSE, predefined_type = n1-standard-1
2019-06-08 18:35:34> Operation running...
2019-06-08 18:35:37> Operation running...
2019-06-08 18:35:43> Operation complete in 6 secs
2019-06-08 18:35:44> attempt24-1 VM running
2019-06-08 18:35:44> # Setting up SSH:username = crayn,ssh_overwrite = FALSE,key.pub = C:/Users/crayn/.ssh/id_rsa.pub,key.private = C:/Users/crayn/.ssh/id_rsa
2019-06-08 18:35:44> Using ssh-key files given as C:/Users/crayn/.ssh/id_rsa.pub / C:/Users/crayn/.ssh/id_rsa
2019-06-08 18:35:52> Public SSH key uploaded to instance
2019-06-08 18:35:52> # Testing cluster:
Failed to add the host to the list of known hosts ('C:\\Users\\crayn\\AppData\\Local\\Temp\\RtmpkP30Ts/hosts').
GetConsoleMode on STD_INPUT_HANDLE failed with 6

My session then hangs for several minutes until it times out, although it does creates the VM in my GCP Console.

After doing some investigation with trace, the problem seems to isolate to gce_ssh_addkeys > do_system > system2

It tried running the same arguments through system2 verbosely:

`test_cmd <- "ssh"`
`test_sargs <- c(
  "-v", 
  "-o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile='C:\\Users\\crayn\\AppData\\Local\\Temp\\RtmpkP30Ts/hosts'", " -i ", 
  "'C:\\Users\\crayn\\.ssh\\id_rsa'", "[email protected]", "\"echo attempt25-1 ssh working\""
)
system2(test_cmd, args = test_sargs, wait = TRUE, stdout = "", stderr = "")

This produced the following readout:

OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
debug1: Connecting to 35.203.124.94 [35.203.124.94] port 22.
debug1: Connection established.
debug1: identity file C:\\Users\\crayn/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\crayn/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\crayn/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\crayn/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\crayn/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\crayn/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\crayn/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\crayn/.ssh/id_ed25519-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\crayn/.ssh/id_xmss type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\crayn/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_7.7
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.5
debug1: match: OpenSSH_7.5 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 35.203.124.94:22 as 'crayn'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: one
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-ed25519 SHA256:fJX2gVMR82gN6SlA2BCwZvvwmbt7JlRQc/Xa1+LK/fU
Failed to add the host to the list of known hosts ('C:\\Users\\crayn\\AppData\\Local\\Temp\\RtmpkP30Ts/hosts').
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:R2VhkqCUoT7Clr2qCBH3dC6AFD/4eUJopH2q3szWWMY C:\\Users\\crayn\\.ssh\\id_rsa
debug1: Authentications that can continue: publickey
debug1: Offering public key: RSA SHA256:1GPFycnKhdNiG1HhPpxxc+fmY1oIkRSDF6Dfu7Bg5kk C:\\Users\\crayn/.ssh/id_rsa
debug1: Server accepts key: pkalg rsa-sha2-512 blen 279
debug1: Authentication succeeded (publickey).
Authenticated to 35.203.124.94 ([35.203.124.94]:22).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug1: Sending command: echo attempt25-1 ssh working
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
GetConsoleMode on STD_INPUT_HANDLE failed with 6
debug1: client_input_channel_req: channel 0 rtype [email protected] reply 0

It seems to me that the problem has something to do with writing to the "hosts" file. Do you have any suggestion to resolve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants