!pip install colab-ssh --upgrade
from colab_ssh import launch_ssh_cloudflared, init_git_cloudflared
launch_ssh_cloudflared(password="0000")
[Google Colab] Visual Studio Code를 Colab에 연결하여 사용하기
cloudflared라는 곳에 colab서버를 연결해 주고, vscode에서 그 곳 주소를 통해 연결하는 방식이다.
위에서 Cloudflare를 환경에 맞게 설치해준다. 받은 exe파일을 적당한 경로에 넣어주면 된다.
vscode에서 open ssh config file을 들어간다. 아무것도 없는 상태에서 엔터를 누르면 다음과 같이 config를 작성할 수 있다. 아래를 입력한다.
# Read more about SSH config files: <https://linux.die.net/man/5/ssh_config>
Host *.trycloudflare.com
HostName %h
User root
Port 22
ProxyCommand <cloudflare.exe의 절대경로> access ssh --hostname %h
colab에서 아래와 같이 작성한다.
!pip install colab-ssh --upgrade
from colab_ssh import launch_ssh_cloudflared, init_git_cloudflared
launch_ssh_cloudflared(password="0000")

위와 같이 나온다. 오른쪽 하단의 주소를 복사하면 된다.