Skip to content
This repository has been archived by the owner on Sep 15, 2022. It is now read-only.

Commit

Permalink
Specify ngrok authtoken as param
Browse files Browse the repository at this point in the history
  • Loading branch information
vochicong committed Mar 26, 2020
1 parent 9dff4b4 commit 968210c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ remocolab.setupVNC()
```

3. (Optional) If you want to run OpenGL applications or any programs that use GPU,
Click "Runtime" -> "Change runtime type" in top menu and change Hardware accelerator to GPU.
Click "Runtime" -> "Change runtime type" in top menu and change Hardware accelerator to GPU.
4. Run that cell
5. Then the message that ask you to copy & paste tunnel authtoken of ngrok will appear.
Login to ngrok, click Auth on left side menu, click Copy, return to Google Colaboratory, paste it to the text box under the message and push enter key.
- You can also specify ngrok token to ``remocolab.setupSSHD()`` or ``remocolab.setupVNC()`` in the code like ``remocolab.setupSSHD(ngrok_token = NGROK_TOKEN_VALUE)``.
6. Select your ngrok region. Select the one closest to your location. For example, if you were in Japan, type jp and push enter key.
- You can also specify ngrok region to ``remocolab.setupSSHD()`` or ``remocolab.setupVNC()`` in the code like ``remocolab.setupSSHD(ngrok_region = "jp")``.
7. remocolab setup ngrok and SSH server. Please wait for it done (about 2 minutes)
Expand Down
17 changes: 9 additions & 8 deletions remocolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,16 @@ def _setupSSHDImpl(ngrok_token, ngrok_region):
print(f"ssh {ssh_common_options} -L 5901:localhost:5901 -p {port} {user_name}@{hostname}")
print("✂️"*24)

def setupSSHD(ngrok_region = None, check_gpu_available = False):
def setupSSHD(ngrok_token = None, ngrok_region = None, check_gpu_available = False):
if check_gpu_available and not _check_gpu_available():
return False

print("---")
print("Copy&paste your tunnel authtoken from https://dashboard.ngrok.com/auth")
print("(You need to sign up for ngrok and login,)")
#Set your ngrok Authtoken.
ngrok_token = getpass.getpass()
if not ngrok_token:
print("---")
print("Copy&paste your tunnel authtoken from https://dashboard.ngrok.com/auth")
print("(You need to sign up for ngrok and login,)")
#Set your ngrok Authtoken.
ngrok_token = getpass.getpass()

if not ngrok_region:
print("Select your ngrok region:")
Expand Down Expand Up @@ -266,6 +267,6 @@ def _setupVNC():
universal_newlines = True)
print(r.stdout)

def setupVNC(ngrok_region = None):
if setupSSHD(ngrok_region, True):
def setupVNC(ngrok_token = None, ngrok_region = None):
if setupSSHD(ngrok_token, ngrok_region, True):
_setupVNC()

0 comments on commit 968210c

Please sign in to comment.