Google Colab 을 ssh를 이용해 vscode에서 이용하기

 

Pytorch 강의를 듣다가 Colab을 ssh (원격 접속)을 통해 vscode에서 서버 처럼 이용할 수 있다는 사실을 알아냈다!

 

그렇게 하기 위해서는 먼저 NGROK에서 회원가입을 해 주어야 한다.

 

ngrok

https://ngrok.com/

 

ngrok | Unified Application Delivery Platform for Developers

ngrok is a secure unified ingress platform that combines your global server load balancing, reverse proxy, firewall, API gateway and Kubernetes Ingress Controller to deliver applications and APIs.

ngrok.com

 

 

 

로그인을 하게 되면 다음과 같은 화면을 볼 수 있는데, 우리가 여기서 필요한건 NGROK의 토큰이다.

 

 

다음과 같은 Your Authtoken 탭에 들어가게 되면 

 

 

다음과 같이 내 토큰 주소를 확인할 수 있다.

이를 복사해서 colab으로 가져온다.

 

코랩에서 설정한 내 토큰과 패스워드

 

NGROK_TOKEN 변수에는 위에서 복사한 내용을 붙여넣어주고,

ssh에 접속할 Password를 설정해준다. (내 맘대로 설정해준다.)

 

!pip install colab-ssh

 

다음, 위 명령을 통해 colab-ssh를 설치해주고,

 

from colab_ssh import launch_ssh
launch_ssh(NGROK_TOKEN,PASSWORD)

 

위 코드를 입력해주게 되면 아래와 같이 Host Config가 생성되게 된다.

 

colab_ssh가 생성된 모습

 

 

이를 바탕으로 vscode에서 remote를 이용해 ssh 접속을 실행해주면 된다!

 

 

요렇게 접속이 되는 것을 확인할 수 있다 ㅎㅎㅎㅎ

 

 

인턴 때 서버 접속해서 쓰던 것이 편했어가지고...

유용하다 생각해서!

google colab을 리눅스 서버처럼 사용할 수 있다!!