SSH connection to Google Colaboratory and Transfering files from Google Drive

Do like to access the Google Colaboratory directly from your machine? Running your script via terminal and having shell access? Then there is a good news, just do the followings:

SSH to Google Colaboratory

1. Install colab_ssh on Google Colaboratory

Add cloudflared and password for root user:

2. Install cloudflared on your machine
Downlaod it from here

3. Append the following to your SSH config file (the file is in  ~/.ssh/config)

4. To connect using your terminal, type this command:

The followings are optional if you want to install Anaconda /Pytorch

5. Installing Anaconda on Google Colaboratory machine
Prerequisite:

Download Anaconda, install it and add it to the path:

Refs: [1]

Accessing Google Drive in Google Colaboratory

You can access files with:

1. Mounting Google Drive

Visit the URL in a browser and enter your authorization code
Your drive will be mounted on:

Mounted at /content/drive

You can access your drive in your Jupiter notebook:

via python code:

2. Using PyDrive

Authenticate and create the PyDrive client:

Access your files:

 

To prevent Google Colab from disconnecting, Just create a new cell at the bottom having the following line:

Refs: [1], [2]

0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x