A streamlined solution for accessing Kaggle computational resources via SSH and VS Code, powered by Zrok for secure tunneling.
kagglelink allows you to ssh into Kaggle and leverage those kaggle resources, or you can run kaggles notebook remotely using VSCode, with more coding support, and better development environment
-
A Zrok token is required for establishing the tunnel. Create an account at myZrok.io to get your token.
-
Ensure your account is on the Starter plan to utilize NetFoundry's public Zrok instance.
-
You need to upload your public key to a github repository or a public file hosting service
One line command setup?
Paste this into Kaggle cell
!curl -sS https://raw.githubusercontent.com/bhdai/kagglelink/refs/heads/main/setup.sh | bash -s -- -k <public_key_url> -t <zrok_token>
Note
replace <public_key_url> with the URL of your public key file and <zrok_token> with your Zrok token.
Wait for the setup to finish, you should see something like this at the end
Generate a new SSH key pair on your local machine (if you haven't already):
ssh-keygen -t rsa -b 4096 -C "kaggle_remote_ssh" -f ~/.ssh/kaggle_rsa
Create a github repository and push the ~/.ssh/kaggle_rsa.pub
file to it. Make sure the repository is public. Once finished, you can get the public key URL by navigating to the file in your repository and clicking on the "Raw" button.
Copy the URL from your browser's address bar. It usually takes the form like this https://raw.githubusercontent.com/<username>/<repo_name>/refs/heads/main/<file_path>
Create your zrok account, if you haven't already, go here and change your plan to Starter plan, and then create a new token. Finally visit https://api-v1.zrok.io, you should setup and get your token there
After completing the Kaggle setup, you'll receive a token. Follow these steps on your local machine:
-
Install Zrok locally by following the official installation guide.
For Arch-based distributions, you can use:
yay -S zrok-bin
-
Enable zrok in your local machine
zrok enable <zrok-token>
-
Access your Kaggle instance using the token:
zrok access private <the_token_from_kaggle>
-
This will open a dashboard displaying your connection details, including a local address like
127.0.0.1:9191
.
For VSCode check out the old instrunction (will update this eventually)
Connect to your Kaggle instance via SSH:
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ~/.ssh/kaggle_rsa -p 9191 root@127.0.0.1
Note: The port (e.g., 9191) generally remains consistent across sessions, so no need to adjust it for each new instance.
To simplify future connections, add this configuration to your ~/.ssh/config
file:
Host Kaggle
HostName 127.0.0.1
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
IdentityFile ~/.ssh/kaggle_rsa
Port 9191
User root
With this configuration, you can simply use ssh Kaggle
to connect.
Transfer files between your local machine and Kaggle instance:
# From local to remote
rsync -e "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ~/.ssh/kaggle_rsa -p 9191" <path_to_local_file> root@127.0.0.1:/kaggle/working
# From remote to local
rsync -e "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ~/.ssh/kaggle_rsa -p 9191" root@127.0.0.1:<path_to_remote_file> <local_destination_path>
Note
If you're using the Starter plan, they only offer 2 environment connection on this plan one for you local machine, one for kaggle instance. Each time you ssh into kaggle make sure to visit https://api-v1.zrok.io/ to release the previous kaggle instance or you can use zrok disable
(run this while connected via SSH to kaggle) before you ending the ssh connection
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.