This guide explains how to set up SSH access through Cloudflare Argo Tunnel using the Cloudflared binary. This setup provides a secure way to access your server, including instructions for running it on Google Colab.
- A client machine running a Unix-like operating system (Linux, macOS, etc.).
- Cloudflared binary installed on your machine.
- SSH client installed.
-
Download the latest Cloudflared
.deb
package from Cloudflare Downloads. -
Open a terminal and navigate to the directory where the
.deb
file is located:cd ~/Downloads
-
Install the package using
dpkg
:sudo dpkg -i cloudflared-linux-amd64.deb
- Use the
which
command to find the absolute path of the installed Cloudflared binary:The output should be something likewhich cloudflared
/usr/local/bin/cloudflared
.
-
Open your SSH config file with a text editor. If the file does not exist, create it:
nano ~/.ssh/config
-
Append the following configuration to the SSH config file, replacing
<PUT_THE_ABSOLUTE_CLOUDFLARE_PATH_HERE>
with the path you obtained from thewhich
command:Host *.trycloudflare.com HostName %h User root Port 22 ProxyCommand <PUT_THE_ABSOLUTE_CLOUDFLARE_PATH_HERE> access ssh --hostname %h
For example, if the path to the Cloudflared binary is
/usr/local/bin/cloudflared
, the configuration should be:Host *.trycloudflare.com HostName %h User root Port 22 ProxyCommand /usr/local/bin/cloudflared access ssh --hostname %h
-
Save the changes and close the editor. In nano, press
Ctrl+X
, thenY
, and finallyEnter
.
- You can now test the SSH connection to your server via Cloudflare Tunnel:
ssh your-server-name.trycloudflare.com
To set up SSH access on Google Colab using Cloudflared, follow these steps:
-
Open a new Colab notebook.
-
Run the following code in a Colab cell:
# Install colab_ssh on google colab !pip install colab_ssh --upgrade from colab_ssh import launch_ssh_cloudflared, init_git_cloudflared launch_ssh_cloudflared(password="root")
-
This code will install the
colab_ssh
package, set up an SSH tunnel using Cloudflared, and display the SSH command to connect to the Colab instance. -
Use the displayed SSH command to connect to your Colab instance from your terminal:
ssh root@<displayed-ssh-address>
- Ensure that Cloudflared is properly installed and the path in the SSH config file is correct.
- Verify that your server is properly configured to use Cloudflare Argo Tunnel for SSH access.
This project is licensed under the MIT License - see the LICENSE file for details.