WassimBenzarti / colab-ssh

Connect to Google Colab using SSH
https://pypi.org/project/colab-ssh/
MIT License
981 stars 127 forks source link

Error while trying to connect #94

Closed RadhikaBansal97 closed 2 years ago

RadhikaBansal97 commented 3 years ago

Hi,

I am getting this error while connecting to host. Please help me with this.

Screenshot 2021-10-03 154353

WassimBenzarti commented 3 years ago

Hello @bansal1997, Welcome to the colab-ssh community!

Did you finish the client machine configuration ? Did you add the few lines in your SSH config ?

RadhikaBansal97 commented 3 years ago

Hi @WassimBenzarti , Yes I added those lines in the config file.

Here is the snippet-

Host *.trycloudflare.com
    HostName %h
    User root
    Port 22
    ProxyCommand "C:\Users\radhika\Downloads\cloudflared-linux-amd64 access ssh --hostname %h"
WassimBenzarti commented 2 years ago

Hi @WassimBenzarti , Yes I added those lines in the config file.

Here is the snippet-

Host *.trycloudflare.com
  HostName %h
  User root
  Port 22
  ProxyCommand "C:\Users\radhika\Downloads\cloudflared-linux-amd64 access ssh --hostname %h"

Hey @bansal1997, apologies for the late reply. I have been busy with work lately. I think the problem with your setup is that you downloaded the cloudflared binary of Linux not windows. I guess your OS is Windows 10 right ?

To download cloudflared for Windows, you need to download from the following section: image

RadhikaBansal97 commented 2 years ago

Hi @WassimBenzarti ,

Thank you for your reply!!

I downloaded the executable cloudflared file for windows and added the path in config file but still the same problem persists.

Host *.trycloudflare.com
    HostName %h
    User root
    Port 22
    ProxyCommand "C:\Users\radhi\Downloads\Softwares\cloudflared-windows-amd64 access ssh --hostname %h"

I have a doubt here, you have mentioned that after downloading the cloudflared file(executable for windows) add the absolute path to cloudflared binary. But I am not getting where is this binary file? Sorry if this sounds foolish, I am new to this.

Screenshot 2021-10-09 191340

WassimBenzarti commented 2 years ago

Hey @bansal1997,

Yes the message is not very clear, it should be "After you put the file somewhere on your computer, you need to copy the absolute path to that file (so you can paste it in the config file on Step 2)". Which means, if you put the downloaded binary cloudflared.exe in C:\my-folder\, try to copy the path (which is C:\my-folder\cloudflared.exe ) and paste in the placeholder <PUT_THE_ABSOLUTE_CLOUDFLARE_PATH_HERE>.

RadhikaBansal97 commented 2 years ago

I have tried to connect many times but it doesn't work. Let me know if you think of any reason behind this behavior.

WassimBenzarti commented 2 years ago

Can you connect via the command line using the command ssh <URL> ? (without VSCode)

RadhikaBansal97 commented 2 years ago

It gives this error while trying to connect with terminal.

CreateProcessW failed error:2
posix_spawnp: No such file or directory
WassimBenzarti commented 2 years ago

Try to remove the quotes around the ProxyCommand in the ssh config file

RadhikaBansal97 commented 2 years ago

Nothing seems to work :(

WassimBenzarti commented 2 years ago

Nothing seems to work :(

I will be uploading a video on how to use colab-ssh tonight, I will put the link here once the upload is completed.

EDIT: Here's the link to the video :) https://www.youtube.com/watch?v=Q78_MMaNe_U

RadhikaBansal97 commented 2 years ago

Hyy @WassimBenzarti , Thank you for this detailed video.

I followed your instruction and now it gives me below error while trying to connect with Terminal (Not able to connect with VS code as well)

ERR failed to connect to origin error="websocket: bad handshake" originURL=https://das-layout-mailman-restore.trycloudflare.com websocket: bad handshake kex_exchange_identification: Connection closed by remote host

aqilakmal commented 2 years ago

Hey, I also have the same problem.

This part works fine: colab

The absolute path of cloudflared: C:\Users\muham\colab-ssh\cloudflared-windows-amd64.exe

SSH Config file

Host *.trycloudflare.com
    HostName %h
    User root
    Port 22
    ProxyCommand ‪C:\Users\muham\colab-ssh\cloudflared-windows-amd64.exe access ssh --hostname %h

When using terminal:

> ssh carter-rangers-drops-pg.trycloudflare.com
CreateProcessW failed error:2
posix_spawnp: No such file or directory

When using VS code: Failed to connect to the remote extension host server (Error: The process tried to write to a nonexistent pipe)

WassimBenzarti commented 2 years ago

This is weird, it might be a problem with parsing the URL. As a workaround, try to get the URL from the cloudflared.log file (you will find this file in your Google Colab file browser).

aqilakmal commented 2 years ago

I still have the same error.

When trying to use the link from cloudflared.log:

[09:44:38.280] Using SSH config file "C:\Users\muham\.ssh\config"
[09:44:38.281] Remote command length: 6017/8192 characters
[09:44:38.281] Running script with connection command: ssh -T -D 60671 -F "C:\Users\muham\.ssh\config" "https://liability-continue-officially-walter.trycloudflare.com" powershell
[09:44:38.284] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[09:44:38.528] > ]0;C:\WINDOWS\System32\cmd.exe
[09:44:38.529] Got some output, clearing connection timeout
[09:44:38.551] > CreateProcessW failed error:2
[09:44:38.576] > posix_spawnp: No such file or directory
[09:44:38.605] > The process tried to write to a nonexistent pipe.

When copying from the colab output:

<...same...>
[09:46:30.197] Running script with connection command: ssh -T -D 52317 -F "C:\Users\muham\.ssh\config" "liability-continue-officially-walter.trycloudflare.com" powershell
<...same...>
[09:46:30.518] > The process tried to write to a nonexistent pipe.
WassimBenzarti commented 2 years ago

@AqilAkmal, Again, try to use the terminal, not VSCode. If it's solved on the terminal we can eliminate several possibilities.

Edit: @AqilAkmal Your issue with VSCode is a completely different problem. Check this issue #101, I believe it's the same type of problem.

aqilakmal commented 2 years ago

In terminal it gives the same error:

C:\Users\muham>ssh https://swedish-riders-plugins-thou.trycloudflare.com
CreateProcessW failed error:2
posix_spawnp: No such file or directory
C:\Users\muham>ssh swedish-riders-plugins-thou.trycloudflare.com
CreateProcessW failed error:2
posix_spawnp: No such file or directory

In VSCode, I followed issue #101 by adding this in settings:

"remote.SSH.configFile": "C:\\Users\\muham\\.ssh\\config",
"remote.SSH.remotePlatform": {
    "https://swedish-riders-plugins-thou.trycloudflare.com": "linux",
    "swedish-riders-plugins-thou.trycloudflare.com": "linux"
}

but it still gives the same error:

[19:13:18.694] Using SSH config file "C:\Users\muham\.ssh\config"
[19:13:18.694] Running script with connection command: ssh -T -D 56659 -F "C:\Users\muham\.ssh\config" "https://swedish-riders-plugins-thou.trycloudflare.com" bash
[19:13:18.696] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[19:13:18.973] > ]0;C:\WINDOWS\System32\cmd.exeCreateProcessW failed error:2
[19:13:18.974] Got some output, clearing connection timeout
[19:13:18.979] > posix_spawnp: No such file or directory
> The process tried to write to a nonexistent pipe.

edit: added non-https link in remote.SSH.remotePlatform and terminal, still gave the same error

RadhikaBansal97 commented 2 years ago

Hyy @WassimBenzarti , I was successfully able to connect to Colab VM through VS code. I was facing the issue because I was choosing windows machine while trying to connect, but after going through this issue #101, I selected Linux and it connected smoothly.

Thank you for all your help!!

aqilakmal commented 2 years ago

Hey, I have solved my issue. TLDR: I don't actually know exactly what and why it works.

Here are some of the steps that I took:

  1. At first, I got this error when running in terminal: CreateProcessW failed error:2 posix_spawnp: No such file or directory
  2. I ran ipconfig /flushdns as I thought the issue got something to do with my DNS.
  3. I reset my network in the Windows settings and restart my computer.
  4. I ran colab-ssh again on colab.
  5. I copied (ssh url) on terminal and got this error:
    2021-10-13T14:59:31Z ERR failed to connect to origin error="dial tcp: lookup ribbon-light-preservation-liberia.trycloudflare.com: no such host" originURL=https://ribbon-light-preservation-liberia.trycloudflare.com
    dial tcp: lookup ribbon-light-preservation-liberia.trycloudflare.com: no such host
    kex_exchange_identification: Connection closed by remote host
  6. I delete a file called "known_hosts" which is in the same directory as the ssh config file.
  7. I restarted my computer, ran colab, copied (ssh url) and got the same error as step 5.
  8. I decided to factory reset the runtime in colab, ran colab-ssh, copied (ssh url) and it works! It also works in VSCode now if I choose Linux.

Hopefully, someone can find out the reason mine doesn't work so others can benefit. Anyways, thank you @WassimBenzarti and contributors for creating such a great project!

WassimBenzarti commented 2 years ago

I am very happy to hear that you solved the issue. Thank you so much @AqilAkmal for sharing the detailed steps after you got it to work ☺️ . That will definitely help anyone encountering this issue.

Unfortunately, it's hard to tell the main problem for this, but I encourage anyone who solved this issue to share with us the steps they followed to fix this.

Hezhexi2002 commented 1 year ago

@WassimBenzarti Hi,sorry to bother you,I can successfully connect the colob with my terminal and vscode shown below: image a55eecf9d9b139d514e19669ba35f7d but when I use vscode to connect it will disconnect from colab after a period of time like this: image I have use a js script to auto-connect colab so why the vscode still can't keep the connection as expected,Is this a limitation of colab itself or something else?I would appreciate it if you can give me some advice:-)