Skip to content

Instantly share code, notes, and snippets.

View siddharthksah's full-sized avatar
📈

Siddharth Kumar Sah siddharthksah

📈
View GitHub Profile
@siddharthksah
siddharthksah / jupyter_remote_tunnel.py
Created March 15, 2023 09:11
Connect to a remote server via SSH, install Anaconda, launch Jupyter Lab, and tunnel its port to the local machine on macOS
# A Python script that allows a user to connect to a remote server via SSH, install Anaconda, start Jupyter Lab on the remote server, and then forward the Jupyter Lab port to the local machine using an SSH tunnel. The user can then access the Jupyter Lab interface on their local machine using a web browser.
# The script uses the paramiko library to create an SSH client object and connect to the remote server. It prompts the user for the remote server's hostname, username, and password. If the connection is successful, the script installs Anaconda on the remote server if it is not already installed, and starts Jupyter Lab on the remote server.
# After starting Jupyter Lab on the remote server, the script creates an SSH tunnel to forward the Jupyter Lab port from the remote server to the local machine. It then opens the Jupyter Lab URL in the user's default web browser and prompts the user to stop Jupyter Lab when they are finished.
# The script contains several functions:
# install_conda(ssh): This functio