오픈소스

[VSCode] SSH 터미널 원격 개발환경 설정

 케이군  2024. 7. 10. 11:22

개요


  • VS Code의 확장 프로그램 Remort - SSH를 사용하여 원격지 서버의 코드를 편집

 

 

설정방법


1. VS CODE 확장 프로그램 설치

확장 (Ctrl + Shift + X) 으로 들어가 검색창에 ssh를 검색을 합니다.

 

 

2. 확장 프로그램 호스트 등록

확장 프로그램에 들어가면 원격 탐색기가 나옵니다. 톱니바퀴 모양을 누르시면 설정을 할 수 있습니다.

사용자 지정 SSH 파일의 경로를 지정해 줍니다.

 

다시 톱니바퀴를 누르고 파일을 수정합니다.

 

config 파일을 작성합니다.

IdentityFile 부분은 비워둘 경우 ID/PW를 통해 접속이 가능합니다.

Host hostname
  HostName hostname
  User username
  IdentityFile C:\Users\users\.ssh\id_rsa

 

매번 ID/PW를 입력하는 것이 번거롭기 때문에 키파일을 생성해서 등록합니다.

원격 서버에서 ssh-kegen을 사용하여 키를 생성합니다.

$ ssh-keygen -t rsa -b 4096
Generating public/private rsa key pair.
Enter file in which to save the key (/home/tsuser/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/tsuser/.ssh/id_rsa
Your public key has been saved in /home/tsuser/.ssh/id_rsa.pub
The key fingerprint is:

 

생성된 퍼블릭 키를 서버에 등록합니다.

$ cat id_rsa.pub >> authorized_keys

 

id_rsa 파일은 다운받아 SSH 설정 경로에 넣어두면 됩니다.