'기타'에 해당되는 글 8건

  1. 2025.02.24 팀뷰어 teamViewer
  2. 2025.02.04 chatGpt fine-tuning모델
  3. 2025.02.04 chatGPT에 custom GPT 연동 1
  4. 2024.07.08 SpreadJs에서 .sjs파일 사용
  5. 2024.05.23 엑셀 매크로 관련
  6. 2023.11.18 git 복사 (미러링)
  7. 2023.11.18 git submodule
  8. 2023.11.09 github

팀뷰어 teamViewer

기타 2025. 2. 24. 11:37

 

팀뷰어로 원격 pc를 제어하려면
host PC에 teamViewer host를 설치해야한다. (라이선스 있다고 눌러야 뜨네요)

참고링크: https://m.blog.naver.com/terry_daddy/223284278249

Posted by yongary
,

chatGpt fine-tuning모델

기타 2025. 2. 4. 13:48

customGPT모델은 openAPI로 호출이 안되는 현상이 있네요.

 

그래서 자체훈련을 시키려면 fine-tuning모델이 맞고,
아래와 같이 생성하면 됩니다.

 

✅ OpenAI Fine-Tuning 모델 생성 방법 (처음부터 끝까지)

OpenAI에서 Fine-Tuning 모델을 생성하는 과정처음부터 끝까지 단계별로 설명하겠습니다. 🚀
Fine-Tuning을 통해 GPT-3.5 Turbo 또는 GPT-4를 특정한 스타일, 문체, 데이터에 맞게 최적화할 수 있습니다.


📌 1. Fine-Tuning 개요

Fine-Tuning이란?

Fine-Tuning이란 기존 OpenAI 모델(GPT-3.5-Turbo, GPT-4)을 사용자의 특정 데이터에 맞춰 재훈련하는 과정입니다.

사용 사례:

  • 특정 고객 응대 방식을 학습 (예: 콜센터 대응, 법률 상담)
  • 특정 전문 용어를 반영한 챗봇 생성 (예: 의학, 법률, 금융)
  • 기존 데이터 기반으로 맞춤형 답변 생성 (예: 기업 내부 문서 요약)

📌 2. Fine-Tuning에 필요한 사전 준비

✅ OpenAI API 키 발급

Fine-Tuning을 하려면 OpenAI API 키가 필요합니다.

  1. OpenAI API 대시보드에 접속
  2. "Create API Key"를 클릭하여 새로운 API 키 생성
  3. API 키를 복사하여 보관 (한 번만 표시됨)

📌 3. Fine-Tuning 데이터 준비

Fine-Tuning을 하려면 **훈련 데이터(training data)**를 만들어야 합니다.
OpenAI는 JSONL(JSON Lines) 형식의 데이터를 요구합니다.

✅ Fine-Tuning 데이터 형식

Fine-Tuning 데이터는 "messages" 형식으로 작성됩니다.

 

(json형식 예제)
{"messages": [
    {"role": "system", "content": "너는 친절한 금융 상담사야."},
    {"role": "user", "content": "대출 금리가 어떻게 되나요?"},
    {"role": "assistant", "content": "현재 대출 금리는 연 3.5%입니다."}
]}


jsonl형식.필요

{"messages": [{"role": "system", "content": "너는 친절한 채권 전문가야."}, {"role": "user", "content": "채권 회수 절차가 어떻게 되나요?"}, {"role": "assistant", "content": "채권 회수 절차는 1) 채무자 연락 2) 독촉장 발송 3) 법적 조치 순으로 진행됩니다."}]}
{"messages": [{"role": "system", "content": "너는 친절한 채권 전문가야."}, {"role": "user", "content": "부실채권을 매각할 수 있나요?"}, {"role": "assistant", "content": "네, 부실채권은 채권 매입 기관을 통해 매각할 수 있습니다."}]}

 

 
 

📌 JSONL 파일을 만들고, .jsonl 확장자로 저장해야 합니다.


📌 4. Fine-Tuning 데이터 업로드

OpenAI API를 사용하여 준비한 JSONL 파일을 업로드합니다.

✅ JSONL 파일 업로드 (파일 ID 얻기)

curl -X POST "https://api.openai.com/v1/files" \
  -H "Authorization: Bearer YOUR_OPENAI_API_KEY" \
  -H "Content-Type: multipart/form-data" \
  -F "file=@training_data.jsonl" \
  -F "purpose=fine-tune"



응답예시:
{
  "id": "file-abc123",
  "object": "file",
  "bytes": 12345,
  "created_at": 1700000000,
  "filename": "training_data.jsonl",
  "purpose": "fine-tune"
}
 
 

"id" 값을 저장 (file-abc123) → Fine-Tuning을 수행할 때 사용됩니다.


 

📌 5. Fine-Tuning 실행

이제 Fine-Tuning을 실행하여 맞춤형 모델을 학습시킵니다.

✅ Fine-Tuning 모델 생성 요청

curl -X POST "https://api.openai.com/v1/fine_tuning/jobs" \
  -H "Authorization: Bearer YOUR_OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-3.5-turbo",
    "training_file": "file-abc123",
    "hyperparameters": {
      "n_epochs": 3
    }
  }'


응답 예시:

{
  "id": "ftjob-xyz789",
  "object": "fine_tuning.job",
  "model": "gpt-3.5-turbo",
  "training_file": "file-abc123",
  "status": "running",
  "created_at": 1700000000
}
 

✅ "id" (ftjob-xyz789)가 Fine-Tuning 작업의 ID입니다.
✅ 훈련이 완료되면 새로운 모델 ID가 생성됩니다.


📌 6. Fine-Tuning 진행 상태 확인

Fine-Tuning이 얼마나 진행되었는지 확인하려면 아래 명령어를 실행합니다.

curl -X GET "https://api.openai.com/v1/fine_tuning/jobs/ftjob-xyz789" \
  -H "Authorization: Bearer YOUR_OPENAI_API_KEY"

응답 예시: 
{
  "id": "ftjob-xyz789",
  "status": "succeeded",
  "fine_tuned_model": "ft:gpt-3.5-turbo:your-org:custom-model"
}
 
 

Fine-Tuning이 완료되면 "fine_tuned_model" 값이 생성됩니다.
✅ "ft:gpt-3.5-turbo:your-org:custom-model"이 새로운 모델 ID입니다.


📌 7. Fine-Tuned 모델 사용 (API 호출)

Fine-Tuning이 완료되면 새로운 모델 ID를 사용하여 API 호출이 가능합니다.

✅ Fine-Tuning 모델 호출 예제

curl https://api.openai.com/v1/chat/completions \
  -H "Authorization: Bearer YOUR_OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "ft:gpt-3.5-turbo:your-org:custom-model",
    "messages": [{"role": "user", "content": "채권 회수 절차가 어떻게 되나요?"}],
    "temperature": 0.7
  }'​

📌 Fine-Tuned 모델이 기존 GPT-3.5보다 더 정확하게 원하는 답변을 생성합니다.


📌 8. Fine-Tuned 모델 삭제 (필요할 경우)

Fine-Tuning 모델을 더 이상 사용하지 않으려면 삭제할 수 있습니다.

✅ 모델 삭제 요청

bash
복사편집
curl -X DELETE "https://api.openai.com/v1/models/ft:gpt-3.5-turbo:your-org:custom-model" \ -H "Authorization: Bearer YOUR_OPENAI_API_KEY"

📌 이 작업은 영구적이므로 주의해야 합니다.


🚀 결론 (Fine-Tuning 요약)

1) JSONL 형식으로 Fine-Tuning 데이터 준비
2) API를 사용하여 JSONL 파일 업로드 (/v1/files)
3) Fine-Tuning 실행 (/v1/fine_tuning/jobs)
4) 모델 학습이 완료되면 Fine-Tuning 모델 ID 확인
5) Fine-Tuned 모델을 API에서 호출하여 사용
6) 필요할 경우 Fine-Tuned 모델 삭제 가능

Posted by yongary
,

(참고: open API를 이용한 custom GPT는 불가능함, 내부 api로 외부데이터 연동은 가능)

1. OpenAI 플랫폼에서 Custom GPT 생성하기

Custom GPT를 설정하려면 OpenAI 플랫폼에서 새로운 Custom GPT를 생성해야 합니다.

1.1. OpenAI 플랫폼 접속

  1. OpenAI Custom GPT 페이지로 이동
  2. 로그인 후 상단의 My GPTs 메뉴 클릭
  3. "Create a GPT" 버튼을 클릭하여 새로운 Custom GPT 생성 시작

2. Custom GPT 설정 과정

Custom GPT는 OpenAI의 Guided Setup을 통해 설정할 수 있습니다.
이 과정에서는 GPT의 성격, 역할, 학습 데이터, API 기능 설정을 조정할 수 있습니다.

2.1. 기본 정보 입력

  • GPT의 이름 설정 → (예: "채권 전문가 GPT")
  • 설명 입력 → (예: "이 GPT는 채권 회수 및 법률 상담을 위한 맞춤형 AI입니다.")

2.2. 역할 및 동작 방식 정의 (Instructions)

Custom GPT의 동작 방식을 정의하는 가장 중요한 과정입니다.

✅ "Instructions" 탭에서 설정할 내용

  1. Assistant Instructions
    → GPT가 어떻게 행동해야 하는지 설명
  2. text
    복사편집
    당신은 금융 및 법률 전문가로서 채권 회수와 관련된 법률 상담을 제공합니다. 사용자의 질문에 대해 구체적인 법률 조항을 참조하며, 금융 기관의 실무적인 조언을 제공합니다.
  3. User Instructions
    → 사용자가 Custom GPT를 어떻게 사용할지 안내
  4. text
    복사편집
    질문을 작성할 때, 관련된 법률 조항이나 금융 용어를 포함해 주세요. 예시: "대여금 반환 청구 소송을 진행하려면 어떤 절차를 따라야 하나요?"

2.3. 추가적인 데이터 업로드 (Knowledge)

사용자가 Custom GPT에 대한 추가 정보를 제공할 수도 있습니다.

  • FAQ 데이터 업로드 (CSV, JSON 형식)
  • PDF, 텍스트 문서 업로드 (예: 회사 내부 지침, 법률 문서 등)

예시:

  • 금융 기관의 채권 회수 정책을 포함한 PDF 파일 업로드
  • 법률 상담 시 자주 묻는 질문(FAQ) 데이터 업로드

2.4. API 호출 및 도구 사용 설정 (Actions)

Custom GPT는 API 호출 및 외부 도구(Functions)와 연동할 수도 있습니다.

  • 예를 들어, Spring Boot API, Google 검색, 데이터베이스 API 등을 호출 가능

예제:

{
  "name": "채권 회수 API",
  "description": "고객의 채권 정보를 조회하고 법률 절차를 안내합니다.",
  "parameters": {
    "채권자명": {
      "type": "string",
      "description": "채권자의 이름"
    },
    "채무자명": {
      "type": "string",
      "description": "채무자의 이름"
    }
  }
}

이 기능을 활용하면 API를 직접 호출하여 최신 정보를 제공하는 Custom GPT를 만들 수 있습니다.


3. Custom GPT를 API에서 호출하는 방법

Custom GPT를 OpenAI API에서 사용하려면, API에서 model 값을 Custom GPT ID로 변경하면 됩니다.

✅ Custom GPT API 호출 예제 (Java)

import okhttp3.*;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.IOException;

@Service
public class OpenAICustomService {
    private static final String API_URL = "https://api.openai.com/v1/chat/completions";
    private final OkHttpClient client = new OkHttpClient();

    @Value("${openai.api.key}")
    private String apiKey;

    @Value("${openai.custom.gpt.id}") // Custom GPT ID (예: gpt-4-custom-XXXXX)
    private String customGptId;

    public String getCustomGptResponse(String userInput) throws IOException {
        String json = "{"
                + "\"model\":\"" + customGptId + "\","
                + "\"messages\":[{\"role\":\"user\",\"content\":\"" + userInput + "\"}],"
                + "\"temperature\":0.7"
                + "}";

        RequestBody body = RequestBody.create(json, MediaType.get("application/json"));

        Request request = new Request.Builder()
                .url(API_URL)
                .header("Authorization", "Bearer " + apiKey)
                .header("Content-Type", "application/json")
                .post(body)
                .build();

        try (Response response = client.newCall(request).execute()) {
            if (!response.isSuccessful()) {
                throw new IOException("Unexpected code " + response);
            }

            ObjectMapper mapper = new ObjectMapper();
            JsonNode rootNode = mapper.readTree(response.body().string());
            return rootNode.get("choices").get(0).get("message").get("content").asText();
        }
    }
}

설정 완료 후 API에서 Custom GPT를 호출하면, 사전에 설정한 역할, 동작 방식, 지식 등을 반영한 응답을 반환합니다.


4. 결론

OpenAI API에서 Custom GPT를 사용하려면 먼저 OpenAI 플랫폼에서 설정이 필요합니다.
사전 설정을 통해 특정한 업무(법률, 금융, IT 등)에 최적화된 GPT를 만들 수 있습니다.
API에서 model 값을 Custom GPT ID로 변경하면 사전 설정이 반영된 맞춤형 응답을 받을 수 있습니다.

 

 

5. customGptId 조회 방식

curl https://api.openai.com/v1/models \
  -H "Authorization: Bearer YOUR_OPENAI_API_KEY"

 

 

 

6. custom GPT 구성(Config)

- 우측 큰화면의 상단에 GPT제목을 누르고, 편집을 누른 후, "구성"탭에서 설정.

인증형식은 API key로 하고, https://platform.openai.com/ 에서 카드설정+발급받은 키를 이용하게 되며,
인증방식은 기본이 아닌->  "Bearer" 로 설정하는게 편함.

 

심플 get용 스키마:

{
  "openapi": "3.1.0",
  "info": {
    "title": "간단한 GET API",
    "description": "GET 요청을 받아 텍스트를 반환하는 API",
    "version": "v1.0.0"
  },
  "servers": [
    {
      "url": "https://api.example.com"
    }
  ],
  "paths": {
    "/hello": {
      "get": {
        "summary": "텍스트 반환",
        "operationId": "getHello",
        "responses": {
          "200": {
            "description": "성공적인 응답",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "Hello, GPT!"
                }
              }
            }
          }
        }
      }
    }
  }
}

 

 

post용 스키마:

{
  "openapi": "3.1.0",
  "info": {
    "title": "채권 조회 API",
    "description": "채권자 및 채무자 정보를 입력하면 채권 상태를 반환합니다.",
    "version": "v1.0.0"
  },
  "servers": [
    {
      "url": "https://api.example.com"
    }
  ],
  "paths": {
    "/getDebtStatus": {
      "post": {
        "summary": "채권 상태 조회",
        "operationId": "getDebtStatus",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DebtRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "채권 상태 응답",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DebtResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "DebtRequest": {
        "type": "object",
        "properties": {
          "채권자명": {
            "type": "string",
            "description": "채권자의 이름"
          },
          "채무자명": {
            "type": "string",
            "description": "채무자의 이름"
          }
        },
        "required": ["채권자명", "채무자명"]
      },
      "DebtResponse": {
        "type": "object",
        "properties": {
          "결과": {
            "type": "string",
            "description": "응답 상태 (성공 또는 실패)"
          },
          "채권 상태": {
            "type": "string",
            "description": "채권의 현재 상태 (예: 연체, 회수 완료 등)"
          },
          "회수 가능 금액": {
            "type": "number",
            "description": "현재 회수 가능한 금액 (원화 기준)"
          }
        }
      }
    }
  }
}
Posted by yongary
,

 

spreadJs의 디자이너를 통해 .sjs파일을 만들어 포매팅에 이용할 수 있다.

import React, { useEffect, useRef, useState } from 'react';
import Head from 'next/head';
import GC from '@mescius/spread-sheets'; // 또는 '@grapecity/spread-sheets'
import '@mescius/spread-sheets-resources-ko';
import '@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css';

const HomePage = () => {
  const containerRef = useRef(null);
  const [spread, setSpread] = useState(null);

  useEffect(() => {
    if (containerRef.current && !spread) {
      const newSpread = new GC.Spread.Sheets.Workbook(containerRef.current, { sheetCount: 1 });
      setSpread(newSpread);
      console.log('Spread initialized:', newSpread);

      // .sjs 파일 로드
      fetch('/data/spreadsheet.sjs')
        .then(response => response.json())
        .then(json => {
          newSpread.fromJSON(json);
          console.log('Spread loaded from .sjs file:', json);
        })
        .catch(error => console.error('Error loading .sjs file:', error));
    }
  }, [containerRef, spread]);

  useEffect(() => {
    return () => {
      if (spread) {
        spread.destroy();
      }
    };
  }, [spread]);

  return (
    <div>
      <Head>
        <link rel="stylesheet" href="/scripts/gc.spread.sheets.17.0.7.css" />
      </Head>
      <h1>SpreadJS Example</h1>
      <div ref={containerRef} className="spreadContainer" style={{ top: '240px', bottom: '10px', position: 'relative', height: '500px' }}>
        {/* SpreadJS 워크북이 여기에 표시됩니다 */}
      </div>
    </div>
  );
};

export default HomePage;
Posted by yongary
,

엑셀 매크로 관련

기타 2024. 5. 23. 15:20

엑셀에서 매크로 사용전에 체크사항: 

 

  • 보안 설정: 매크로 실행을 위해서는 엑셀의 매크로 보안 설정을 적절히 조정해야 할 수도 있습니다. 파일 > 옵션 > 보안 센터 > 보안 센터 설정 > 매크로 설정에서 매크로를 활성화할 수 있습니다.
  • 참조 설정: HTTP 요청을 처리하기 위해 Microsoft XML, v6.0 참조를 추가해야 할 수도 있습니다. VBA 편집기에서 도구 > 참조를 선택한 후, 해당 항목을 체크합니다.

개발도구 리본 보이기:
 파일->옵션->리본설정 

 

 

엑셀매크로에서 이미지 전송 예제: 이미지뷰어 필수

Sub SendImageToKakaoTalk()
    Dim imgPath As String
    Dim wsShell As Object

    ' 이미지 파일 경로 설정
    imgPath = "C:\Path\To\Your\Image.jpg"

    ' Shell 객체 생성
    Set wsShell = CreateObject("WScript.Shell")

    ' 이미지 파일 열기
    wsShell.Run Chr(34) & imgPath & Chr(34)
    Application.Wait (Now + TimeValue("0:00:02")) ' 이미지 파일이 열리기를 기다립니다.

    ' 이미지 파일을 복사합니다.
    wsShell.SendKeys "^a", True ' 전체 선택 (Ctrl + A)
    Application.Wait (Now + TimeValue("0:00:01"))
    wsShell.SendKeys "^c", True ' 복사 (Ctrl + C)
    Application.Wait (Now + TimeValue("0:00:01"))

    ' 카카오톡 창 활성화
    AppActivate "카카오톡"
    Application.Wait (Now + TimeValue("0:00:01"))

    ' 카카오톡 대화창으로 이동 (여기서는 예시로 첫 번째 채팅방)
    wsShell.SendKeys "^l", True ' 채팅방 리스트로 이동 (Ctrl + L)
    Application.Wait (Now + TimeValue("0:00:01"))
    wsShell.SendKeys "{TAB}", True ' 첫 번째 채팅방으로 이동
    Application.Wait (Now + TimeValue("0:00:01"))
    wsShell.SendKeys "~", True ' 채팅방 열기 (Enter)
    Application.Wait (Now + TimeValue("0:00:01"))

    ' 이미지 붙여넣기 및 전송
    wsShell.SendKeys "^v", True ' 붙여넣기 (Ctrl + V)
    Application.Wait (Now + TimeValue("0:00:01"))
    wsShell.SendKeys "~", True ' 전송 (Enter)

    ' 다시 엑셀로 포커스 이동
    AppActivate Application.Caption
End Sub

 

 

엑셀매크로에서 Rest API

Sub GetRequestExample()
    Dim xmlhttp As Object
    Dim url As String
    Dim response As String

    ' MSXML2.XMLHTTP 객체 생성
    Set xmlhttp = CreateObject("MSXML2.XMLHTTP")
    
    ' API URL 설정
    url = "https://api.example.com/data"

    ' GET 요청 초기화
    xmlhttp.Open "GET", url, False
    ' 요청 헤더 설정 (필요한 경우)
    xmlhttp.setRequestHeader "Content-Type", "application/json"
    
    ' 요청 보내기
    xmlhttp.send
    
    ' 응답 받기
    response = xmlhttp.responseText
    
    ' 응답 출력
    MsgBox response
    
    ' 객체 해제
    Set xmlhttp = Nothing
End Sub



Sub PostRequestExample()
    Dim xmlhttp As Object
    Dim url As String
    Dim postData As String
    Dim response As String

    ' MSXML2.XMLHTTP 객체 생성
    Set xmlhttp = CreateObject("MSXML2.XMLHTTP")
    
    ' API URL 설정
    url = "https://api.example.com/data"
    
    ' POST 데이터 설정 (JSON 형식 예시)
    postData = "{""name"":""John"",""age"":30}"

    ' POST 요청 초기화
    xmlhttp.Open "POST", url, False
    ' 요청 헤더 설정
    xmlhttp.setRequestHeader "Content-Type", "application/json"
    
    ' 요청 보내기
    xmlhttp.send postData
    
    ' 응답 받기
    response = xmlhttp.responseText
    
    ' 응답 출력
    MsgBox response
    
    ' 객체 해제
    Set xmlhttp = Nothing
End Sub

 

 

다운로드 이미지 예제

Sub DownloadFile()
    Dim http As Object
    Dim url As String
    Dim localFilePath As String
    Dim binaryStream As Object

    ' 다운로드할 파일의 URL
    url = "http://localhost:8080/download/file"

    ' 저장할 파일 경로
    localFilePath = "C:\path\to\save\downloadedfile.ext"

    ' Create XMLHTTP object
    Set http = CreateObject("MSXML2.XMLHTTP")
    http.Open "GET", url, False
    http.send

    If http.Status = 200 Then
        If Not IsNull(http.responseBody) And LenB(http.responseBody) > 0 Then
            ' Create binary stream object
            Set binaryStream = CreateObject("ADODB.Stream")
            binaryStream.Type = 1 ' Binary
            binaryStream.Open
            binaryStream.Write http.responseBody
            binaryStream.SaveToFile localFilePath, 2 ' Save binary data to file
            binaryStream.Close
            MsgBox "File downloaded successfully!"
        Else
            MsgBox "The server returned null or empty response."
        End If
    Else
        MsgBox "Failed to download file. Status: " & http.Status
    End If

    ' Clean up
    Set http = Nothing
    Set binaryStream = Nothing
End Sub
Posted by yongary
,

git 복사 (미러링)

기타 2023. 11. 18. 22:59

Git 저장소의 히스토리를 포함하여 복사해서 다른 저장소로 옮기는 방법

 

1. 기존 저장소를 --mirror로 받는다.
$git clone --mirror <기존_저장소_URL>

 

2. 새 저장소를 만들고 그 URL을 얻은 다음..

 

3. $cd 기존_저장소_URL
    $git push --mirror <새_저장소_URL> 

 

 

Posted by yongary
,

git submodule

기타 2023. 11. 18. 22:51

1 서브모듈 추가하고 싶은 폴더로 가서 

$git submodule add https://github.com/example/submodule.git path/to/submodule

 

2 변경 사항 커밋: 서브모듈을 추가한 후, .gitmodules 파일과 서브모듈 디렉토리에 대한 변경 사항을 커밋합니다.

git add .
git commit -m "Add submodule"

 

3. git push

 

========= 

전체 pull 하고 싶을때
최초한번

git submodule update --init --recursive

 

그 후 

git submodule update --remote --recursive

Posted by yongary
,

github

기타 2023. 11. 9. 22:23

 

ChatGPT

GitHub에서 특정 리포지토리를 clone하고 SSH 키를 설정하여 반복적으로 로그인하지 않도록 하는 방법은 다음과 같습니다:

  1. GitHub 계정 만들기 및 SSH 키 설정:
    • GitHub에 가입하려면 https://github.com/ 에서 가입 프로세스를 따릅니다.
    • 계정을 만들었다면, 로그인하세요.
    • SSH 키를 생성하려면 터미널 또는 명령 프롬프트에서 다음 명령을 실행합니다:이 명령에서 "your_email@example.com" 부분을 본인의 이메일 주소로 바꿉니다. 키 생성 중에 암호를 설정하라는 메시지가 나오면 암호를 설정하세요. 암호는 SSH 키를 사용할 때 필요할 수 있습니다.
    • mathematicaCopy code
      $ssh-keygen -t ed25519 -C "your_email@example.com"
    • 키 생성이 완료되면, 공개 키를 GitHub에 추가해야 합니다. 터미널에서 다음 명령으로 공개 키를 복사합니다:
    • bashCopy code
      $cat ~/.ssh/id_ed25519.pub
      ==> 공개키는  한 줄이며 ssh-ed25519 AAA로 시작하고 이메일로 끝납니다.
      • 공개 키를 클립보드에 복사한 후, GitHub 계정 설정 페이지로 이동하여 "SSH and GPG keys" 섹션에 공개 키를 추가합니다.
  2. 리포지토리 Clone:
    • SSH 키가 GitHub에 등록되었으면, 해당 리포지토리를 clone할 수 있습니다. 터미널에서 다음 명령을 사용하여 리포지토리를 clone합니다:여기서 사용자명과 리포지토리명을 실제 사용자명과 리포지토리 이름으로 바꿉니다.
    • scssCopy code
      $git clone git@github.com:사용자명/리포지토리명.git

 

 

 

만약 A PC에서 생성한 SSH 키를 B PC에서도 사용하려면, A PC에서 생성한 키를 B PC로 복사해야 합니다.

  1. 공개 키와 개인 키 복사 A PC의 SSH 키 파일을 B PC로 이동합니다. 예를 들어, 기본 경로(~/.ssh/id_ed25519와 ~/.ssh/id_ed25519.pub)를 복사합니다.
  2. bash
    코드 복사
    # A PC에서 B PC로 복사 (B PC의 IP가 192.168.1.100이고 사용자명이 user라고 가정) scp ~/.ssh/id_ed25519* user@192.168.1.100:~/.ssh/
  3. 권한 설정 B PC에서 복사한 파일의 권한을 올바르게 설정합니다:
  4. bash
    코드 복사
    chmod 600 ~/.ssh/id_ed25519 chmod 644 ~/.ssh/id_ed25519.pub
  5. SSH 에이전트에 추가 (B PC에서) 복사한 키를 SSH 에이전트에 추가합니다:
  6. bash
    코드 복사
    eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_ed25519 

    혹은 Window에서는 관리자용-PowerShell에서 아래방식이 잘됨.

Start-Service ssh-agent

ssh-add C:\Users\<YourUsername>\.ssh\id_ed25519

 

혹시 git 이 잘 안된다면 $which ssh 를 해보면 /usr/bin/ssh 가 나오는 경우가 있는데,
이걸 "/c/Windows/System32/OpenSSH/ssh" 를 사용하도록 바꿔야 한다.

 

간단하게 mv /usr/bin/ssh /usr/bin/ssh-backup 으로 없애버리면 된다.

Posted by yongary
,